我如何设置 target
在 NLog.config 文件中创建用户应用程序数据目录中的日志文件?
下面是文件的所需位置。
C:\Users\userid\AppData\Local...\LogFile.txt
我尝试设置
fileName
以下几种方式都没有成功。target name="logfile" xsi:type="File" fileName="%APPDATA%/.../LogFile.txt"
target name="logfile" xsi:type="File" fileName="${APPDATA}/.../LogFile.txt"
target name="logfile" xsi:type="File" fileName="${%APPDATA%}/.../LogFile.txt"
最佳答案
您可以通过创建这样的目标来实现这一点:
<target name="logfile" xsi:type="File"
fileName="${specialfolder:folder=ApplicationData}/LogFile.txt"/>
文档可以在 here 中找到.
我希望这有帮助。
关于logging - 在 NLog 文件路径中使用应用数据目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20109171/