当我的布局以$ {pad ......开头时,为什么NLog不产生任何输出

时间:2019-06-09 23:33:12

标签: nlog

请考虑NLog.config中的以下配置文件:

<?xml version="1.0" encoding="utf-8"?>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">

  <!-- 
  See https://github.com/nlog/nlog/wiki/Configuration-file 
  for information on customizing logging rules and outputs.
   -->
  <targets async="true">
    <target xsi:type="Trace" name="DebugView"
            rawWrite="true"
            layout="NEX|${pad:padding=-5:inner=${uppercase:${level}}}|${pad:padding=-16:inner=${callsite:className=true:fileName=false:includeSourcePath=false:methodName=false:includeNamespace=false}}|${message}" />
    <target xsi:type="File" name="LogFile"
            filename="${environment:variable=UserProfile}/logs/TA.Nexdome.Server-${filesystem-normalize:fSNormalize=true:inner=${shortdate}-${windows-identity}-${machinename}.log}"
            layout="${time}|${pad:padding=-5:inner=${uppercase:${level}}}|${pad:padding=-16:inner=${callsite:className=true:fileName=false:includeSourcePath=false:methodName=false:includeNamespace=false}}|${message}" />
  </targets>
  <rules>
    <logger name="*" minlevel="Trace" writeTo="DebugView" />
    <logger name="*" minlevel="Trace" writeTo="LogFile" />
  </rules>
</nlog>

对于目标name="DebugView",如果我修改布局定义以从一开始就删除文字文本NEX|,那么我根本不会得到任何输出。

如果我在${pad前面放了所有东西,甚至只是一个|,我都会得到输出。

这可能是布局逻辑中的错误吗?

1 个答案:

答案 0 :(得分:0)