c# - NLog 不从 XML 配置加载规则

标签 c# logging nlog

配置文件(变量除外)包含数据:

<?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"
      throwExceptions="false">

  <extensions>
    <add assembly="NLog.Extended" />
  </extensions>

  <targets async="True">
    <target name="TraceLogger"
            type="File"
            fileName="${TraceFullPath}"
            archiveFileName="${TraceArchiveFullPath}"
            maxArchiveFiles="100"
            archiveNumbering="Sequence"
            archiveEvery="None"
            layout="${message}" />
  </targets>

  <rules>
    <logger name="*"
            minLevel="Trace"
            writeTo="TraceLogger"
            enabled="True" />
  </rules>
</nlog>

测试执行代码为:

    var configuration = new XmlLoggingConfiguration(configurationPath);
    var factory = new LogFactory(configuration);
    var logger = factory.GetCurrentClassLogger();
    logger.Trace("Message");

调试器显示以下属性值:

configuration.base.LogginRules: Count = 0
configuration.base.AllTargets: Count = 0
logger.Is...Enabled = false (for all levels)

知道我做错了什么吗?

最佳答案

问题很简单:变量和目标值中区分大小写的拼写错误

很抱歉耽误了您的时间

关于c# - NLog 不从 XML 配置加载规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33097775/

相关文章:

nlog - 如何告诉 NLog 记录异常?

c# - NLog:如何控制 LogEventInfo 对象的消息格式?

C# 系统命名空间——为什么我需要导入它?

c# - 为什么要使用 Clone()?

C# : Pass string array to c++ dll/dylib

ios - 在设备控制台中查看 os_log 消息

python - 使用 Python 记录所有错误和标准输出

c# - C#中的Ektron pageID

logging - 在 Azure 中配置文件日志记录以写入 LocalResources 中定义的特定 LocalStorage

c# - 如何让 NLog 输出出现在 Azure 函数的流日志中?