Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

NLog Log and Audit Advanced Target

, 26 May 2010 CPOL
A way to audit your business objects using NLog.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace App.Logger.Targets.ObjectHistoryLogger
{
	/// <summary>
	/// Attribute to define a property as loggable
	/// </summary>
	[global::System.AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
	public sealed class LogPropertyAttribute : Attribute
	{

				/// <summary>
		/// Initializes a new instance of the <see cref="LogAttribute"/> class.
		/// </summary>
		public LogPropertyAttribute()
		{
			MappedName = string.Empty;
			Description = string.Empty;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="LogAttribute"/> class.
		/// </summary>
		/// <param name="mappedName">The logged object mapped name.</param>
		/// <param name="description">The logged object description.</param>
		public LogPropertyAttribute(string mappedName, string description)
		{
			MappedName = mappedName;
			Description = description;
		}

		/// <summary>
		/// Gets the name to be mapped on the target.
		/// With this a logged object can have a different name on the log.
		/// </summary>
		/// <value>The logged object mapped name.</value>
		public string MappedName { get; private set; }

		/// <summary>
		/// Gets the description associated with the logged object.
		/// This is meant to add addicional data to the logged object.
		/// </summary>
		/// <value>The logged object description.</value>
		public string Description { get; private set; }

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

AlexCode
Architect
Switzerland Switzerland
Senior IT Consultant working in Switzerland as Senior Software Engineer.
 
Find more at on my blog.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411022.1 | Last Updated 26 May 2010
Article Copyright 2010 by AlexCode
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid