问题
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.
回答1:
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.
回答2:
As mentioned by @agunn above, I'm posting the snippet that imports properly for me in VS2013:
<?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>
<Description>Adds the logger object</Description>
<Shortcut>nlogger</Shortcut>
</Header>
<Snippet>
<Code Language="CSharp"
Kind="any">
<![CDATA[private static readonly Logger Logger = LogManager.GetCurrentClassLogger();]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
来源:https://stackoverflow.com/questions/13588131/nlog-nlogger-snippet-not-working-visual-studio-2012