NLog:无法找到LayoutRenderer

时间:2015-10-12 15:25:18

标签: nlog

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\文件夹,但我不认为这是问题的根源

但是什么?

1 个答案:

答案 0 :(得分:1)

value="D:\Internal\Logs\"更改为value="D:/Internal/Logs/"fileName="${TargetDirectory}${TraceLogname},以 fileName="${TargetDirectory}/${TraceLogname}