将 NLog 目标从文件更改为 Stackify
Changing NLog target from file to Stackify
我想让我的应用程序在 Stackify 和文本文件上登录。所以我在 web config 中添加一个目标到 nlog 如下:
<extensions>
<add assembly="StackifyLib.nLog"/>
</extensions>
<targets>
<target name="stackify" type="StackifyTarget" globalContextKeys="examplekey1,key2"
mappedContextKeys="" callContextKeys="" logMethodNames="true" />
</targets>
<rules>
<logger name="*" writeTo="stackify" minlevel="Debug" />
</rules>
当我这样做时,日志文件不再更新,即没有任何内容附加到文本文件。知道为什么这会影响其他目标吗?
我是 Stackify 的 Matt。
您需要将 NLog 配置设置为具有 2 个目标和 2 个规则,如此处所示。它应该看起来像这样:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="StackifyLib.NLog"/>
</extensions>
<targets>
<target name="stackify" type="StackifyTarget" logMethodNames="true" logAllParams="true" />
<target xsi:type="File" name="default" fileName="stackifynlog.log" />
</targets>
<rules>
<logger name="*" writeTo="stackify" minlevel="Debug" />
<logger name="*" writeTo="default" minlevel="Debug" />
</rules>
</nlog>
此外,这里是我们文档的 link 和 GitHub 以获取更多信息。
http://support.stackify.com/hc/en-us/articles/205419505-Errors-and-Logs-With-NLog
https://github.com/stackify/stackify-api-dotnet#nlog-2012---v31
谢谢!
我想让我的应用程序在 Stackify 和文本文件上登录。所以我在 web config 中添加一个目标到 nlog 如下:
<extensions>
<add assembly="StackifyLib.nLog"/>
</extensions>
<targets>
<target name="stackify" type="StackifyTarget" globalContextKeys="examplekey1,key2"
mappedContextKeys="" callContextKeys="" logMethodNames="true" />
</targets>
<rules>
<logger name="*" writeTo="stackify" minlevel="Debug" />
</rules>
当我这样做时,日志文件不再更新,即没有任何内容附加到文本文件。知道为什么这会影响其他目标吗?
我是 Stackify 的 Matt。
您需要将 NLog 配置设置为具有 2 个目标和 2 个规则,如此处所示。它应该看起来像这样:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="StackifyLib.NLog"/>
</extensions>
<targets>
<target name="stackify" type="StackifyTarget" logMethodNames="true" logAllParams="true" />
<target xsi:type="File" name="default" fileName="stackifynlog.log" />
</targets>
<rules>
<logger name="*" writeTo="stackify" minlevel="Debug" />
<logger name="*" writeTo="default" minlevel="Debug" />
</rules>
</nlog>
此外,这里是我们文档的 link 和 GitHub 以获取更多信息。
http://support.stackify.com/hc/en-us/articles/205419505-Errors-and-Logs-With-NLog
https://github.com/stackify/stackify-api-dotnet#nlog-2012---v31
谢谢!