How to use NLog’s snippet in VS (Visual Studio) 2012

There are many people out there that just love love love NLog and all it can do for us. NLog takes care of threading, logging levels and many other pieces to the logging out puzzle and packages in this nice little utility. NLog is supported on all Windows Frameworks.

If any of you out there have been using this tool in Visual Studio 2010 and have gotten used to the nlogger snippet, you may have a pouty face when you start using 2012 :(. NLog snippets don’t seem to work in 2012. Wat is one to do. Well after posting some questions online, someone pointed me to this snippet in this Stackoverflow post


<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="">
<CodeSnippet Format="1.0.0">
NLog Logger Snippet
<Code Language="CSharp">
<![CDATA[private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();]]>

If you create a file named nlogger.snippet in the following folder : C:\Users\gcoleman\Documents\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets and paste the above xml code into the file, you will have created a VS 2012 snippet. YAY.. GO YOU!!


Now all you have to do is Open VS 2012 and go to Tools-> Code Snippet Manager. Once there, select the import button and Browse the location of your snippet. Once selected, it will ask you to select the frameworks this should be allowed to be used in. I choose C#, ASP.NET etc.. but you can select anything you want. upon completion, you should be able to start using your new snippet right away!


Happy Coding!


About Gregg Coleman

I am Senior-level Software Engineer working primarily these days with .NET. I have a good working knowledge of ASP.NET MVC, Web Forms, WCF web services and Windows Services. I spend much of my time in the Web Services (SOAP and REST) world in my current job designing and implementing various SOA architectures. I have been in the software engineering industry for about 6 years now and will not now nor ever consider myself an "expert" in programming because there is always so much to learn. My favorite thing about designing software is there are always new emerging technologies and something to learn every day! My current job has me spending much of my job on the bleeding edge of technologies and changing gears all the time, so I'm never bored and always challenged. On my spare time I enjoy weight training, reading and venturing to new places near by. Of course programing and learning new technologies are another hobby of mine.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s