Click here to Skip to main content
15,892,804 members
Articles / Desktop Programming / Windows Forms

NLog Log and Audit Advanced Target

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
26 May 2010CPOL6 min read 42.7K   750   35  
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)


Written By
Architect
Switzerland Switzerland
Senior IT Consultant working in Switzerland as Senior Software Engineer.

Find more at on my blog.

Comments and Discussions