My Thoughts & Views

Logging Errors with NLog a .NET Logging Library

Posted by: intelbot on: March 19, 2009

NLog is a .NET Logging Library, 

Official Site mentions it as follows,

NLog is a .NET logging library designed with simplicity and flexibility in mind. With NLog you can process diagnostic messages emitted from any .NET language, augment them with contextual information, format them according to your preference and send them to one or more targets.

Using it is very easy. Following steps helps you to get started.

(For Visual Studio 2008, Web Applications)
1. Download and install NLog Library 2. If you are using Visual Studio 2008, follow this step as mentioned in my earlier post, to fix issue with Intellisense.   

3. Add reference to NLog.dll.
4. Add the following Entries to web.config
Web.Config Entry
5. Add  following entries to your code behind file  

(for C#)  

using NLog;
using NLog.Targets;
using NLog.Config;
using NLog.Win32.Targets;
6.  Create a Logger object as below in your code behind file
catch(Exception ex)
{
    Logger errLogger = LogManager.GetLogger(“*”);
                    errLogger.Debug(ex.Message);
}

Leave a Reply

Blog Stats

  • 10,535 hits

 

March 2009
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031