NLog在尝试创建记录器时抛出异常:
var configuration = new XmlLoggingConfiguration(configurationPath);
Exception message: LayoutRenderer cannot be found: 'TargetDirectory'
记录器配置:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="NLog.Extended" />
</extensions>
<variables>
<variable name="TargetDirectory"
value="D:\Internal\Logs\" />
...
<targets>
<target name="TraceLog"
xsi:type="File"
fileName="${TargetDirectory}${TraceLogname}"
...
</nlog>
NLog.Extended.dll
显示在bin
文件夹中
硬盘驱动器上存在D:\Internal\Logs\
文件夹,但我不认为这是问题的根源
但是什么?
答案 0 :(得分:1)
将value="D:\Internal\Logs\"
更改为value="D:/Internal/Logs/"
和
fileName="${TargetDirectory}${TraceLogname}
,以
fileName="${TargetDirectory}/${TraceLogname}