Cook Computing

Configuring NLog for Visual Studio 2008

August 1, 2009 Written by Charles Cook

I'm evaluating NLog 1.0 — the latest release — for a project and discovered it doesn't support integration with Visual Studio 2008. I had Visual Studio 2005 installed on another machine and after installing NLog with that version to see which files are installed, I determined the following steps successfully configure NLog for VS 2008:

  1. Install NLog for .NET 2.0.
  2. Download nlogtemplates.zip (contents © Jaroslaw Kowalski) and extract to My Documents\Visual Studio 2008\Templates\ItemTemplates. If you have customized the location of item templates, extract to the appropriate directory.
  3. Download nlogsnippets.zip (contents © Jaroslaw Kowalski) and extract to My Documents\Visual Studio 2008\Code Snippets. If you have customized the location of snippets, extract to the appropriate directory.
  4. Copy the file NLog.xsd from \Program Files\NLog\bin\net-2.0 to Program Files\Microsoft Visual Studio 9.0\Xml\Schemas to enable intellisense when editing NLog configuration.

Once this has been done you will see three NLog configuration templates under My Templates in the Add New Item dialog in VS 2008. They are:

  • A configuration file that defines one File Target (typical).
  • A configuration file that defines one Console Target.
  • An empty configuration file.

One final point: remember to set the Copy To Output Directory property of the NLog config file to Copy Always.