NLog nlogger snippet not working Visual Studio 2012

旧城冷巷雨未停 提交于 2019-12-10 15:07:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!