我的NLog目标是这样的:
<targets>
<target xsi:type="Console" name="console"
layout="${longdate}|${level}|${message}" />
<target xsi:type="File" name="ErrorLog" fileName="${basedir}/error.txt"
layout="${longdate}
Trace: ${stacktrace}
${message}" />
<target xsi:type="File" name="AccessLog" fileName="${basedir}/access.txt"
layout="${shortdate} | ${message}" />
</targets>但是,如果用户不是他们机器上的管理员,这就会产生问题,因为他们没有"Program Files“的写权限。我怎样才能把像%AppData%这样的东西转到NLog而不是BaseDir呢?
发布于 2010-01-04 23:55:44
你要找的是NLog special folders。
示例:
...fileName="${specialfolder:folder=ApplicationData}/Program/file.txt"...发布于 2011-03-25 06:50:28
奥伦的答案应该是正确的答案。然而,在我的生活中,我无法使用nLog 2.0.0.0在我的.NET 4.0网站上使用它。我最终使用了简单的
fileName="${basedir}app_data\logs\${shortdate}.log" 发布于 2011-02-22 14:02:56
${specialfolder:ApplicationData}也适用
https://stackoverflow.com/questions/2000189
复制相似问题