配置文件(变量除外)包含数据:
<?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/