Search code examples
visual-studio-2010visual-studio-2012code-snippetsnlog

NLog nlogger snippet not working Visual Studio 2012


Does anyone know how to get Nlog's nlogger snippet to work in Visual Studio 2012 like it did in 2010? I don't see anything on their forum or on the internet when googing around. Seems like something that people who use Nlog would want back.


Solution

  • Haven't worked out how to get the real snippet installed, so I manually created a snippet to perform the same function as the original did.

    Create the file nlogger.snippet in the following folder:

    My Documents\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets
    

    The contents of the file should be as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
        <CodeSnippet Format="1.0.0">
            <Header>
                <Title>
                    NLog Logger Snippet
                </Title>
                <Shortcut>nlogger</Shortcut>
            </Header>
            <Snippet>
                <Code Language="CSharp">
                    <![CDATA[private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();]]>
                </Code>
            </Snippet>
        </CodeSnippet>
    </CodeSnippets>
    

    Hopefully this helps someone.