【发布时间】:2016-05-05 14:59:16
【问题描述】:
目前我正在使用 NLog 将我的应用程序错误写入文本文件。 除了写入 Azure Blob 存储之外,如何配置 NLog 以将错误消息写入 Azure 流式日志?
【问题讨论】:
标签: c# azure-blob-storage nlog
目前我正在使用 NLog 将我的应用程序错误写入文本文件。 除了写入 Azure Blob 存储之外,如何配置 NLog 以将错误消息写入 Azure 流式日志?
【问题讨论】:
标签: c# azure-blob-storage nlog
Azure 流式日志捕获发送到 Trace 接口的内容。例如,如果您将 NLog 配置为发送到该目标,则可以通过 Visual Studio 中的输出窗口轻松访问它。
这是我配置 NLog.config 以获得此结果的方式:
<targets>
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message} ${exception:format=tostring}" />
<target xsi:type="Trace" name="trace" layout="${logger} ${message} ${exception:format=tostring}" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="f" />
<logger name="*" minlevel="Trace" writeTo="trace" />
</rules>
第一个目标应该类似于您已经拥有的用于记录到文件的目标,第二个目标只是将数据发送到跟踪通道。
希望这会有所帮助!
【讨论】: