如何查询NLog日志文件的路径? [英] How can I query the path to an NLog log file?
本文介绍了如何查询NLog日志文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经为NLog配置了文件目标,如下所示:
I've configured a file target for NLog as follows:
<targets>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target xsi:type="File" name="logfile" fileName="${basedir}/Logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
</target>
</targets>
如何通过NLog的API查询此File
目标的实际文件系统路径(fileName
)?
How can I query the actual filesystem path (fileName
) of this File
target via NLog's API?
推荐答案
可悲的是,该配置似乎是由实际目标评估的,无法在配置中解决.
Sadly it looks like the configuration is evaluated by the actual target and is not resolved in the configuration.
{basedir}
指的是您可以使用的appdomain基本目录只需自己读取此值.
As {basedir}
refers to the appdomain base directory you could simply read this value on your own.
var basedirPath = AppDomain.CurrentDomain.BaseDirectory;
这篇关于如何查询NLog日志文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文