默认情况下,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}
特殊文件夹似乎登录到“我的文档”、“图片”中,所以没有太多用处。关于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>
标签。这是复制/粘贴问题还是准确的? - DiskJunky