【发布时间】:2017-09-22 10:53:15
【问题描述】:
默认情况下,Nlog 记录到默认应用程序文件夹
<target xsi:type="File" name="f"
fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}
${exception:message=tostring}" />
目前我的应用程序位于 C 目录中,我希望 Nlog 登录到特定文件夹中的 D 目录。我读到了
fileName="${tempdir:folder=myapptmp}/sample.log"
和
${specialfolder:dir=String:file=String:folder=Enum}
特殊文件夹似乎登录到 MyDocuments、Pictures。所以用处不大。 Tempdir 我不确定。有没有人之前做过这个或对此有任何想法
我的 Nlog 配置
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!-- add your targets here -->
<target name="File" xsi:type="File"
fileName="D:\Sushil\DwebLogging\log-${date:format=yyyy-MM-dd}.log"
layout="${longdate} ${uppercase:${level}} ${message} ${exception:
format=tostring}" />
<rules>
<logger name="*" minlevel="Trace" writeTo="File" />
</rules>
</nlog>
【问题讨论】:
-
以上示例中没有结束
</targets>标记。复制/粘贴问题还是准确? -
啊..这就是问题所在。谢谢:)
标签: c# .net asp.net-mvc logging nlog