【发布时间】:2021-06-14 19:22:55
【问题描述】:
我在 C# 控制台应用程序中使用 NLog 4.7.10。我的信息、错误和警告消息按预期出现在我的日志文件中,但致命消息永远不会出现。我的代码如下:
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
logger.Fatal("This never appears in the log file!");
logger.Info("This info message is logged in the log file.");
logger.Error("This error message is logged in the log file.");
logger.Warn("This warning message is logged in the log file.");
我认为我的 nlog.config 中的任何内容都不会导致问题:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="d:\tmp\log.txt">
<variable name="defaultLayout" value="${date:format=dd MMM yyyy HH\:mm\:ss} [${level}]: ${message:withException=true}" />
<targets>
<target name="logfile" xsi:type="File"
fileName="${basedir}/logs/foo.log"
archiveOldFileOnStartup="true"
layout="${defaultLayout}"
archiveFileName = "${basedir}/logs/archives/foo ${date:format=yyyy-MM-dd HHmmss}.log"
archiveNumbering = "Rolling" />
<target name="console" xsi:type="ColoredConsole" layout="${defaultLayout}" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
</rules>
</nlog>
什么可以过滤掉致命消息?
【问题讨论】:
-
请在此处创建一个新问题:github.com/NLog/NLog/issues 附上重现问题的示例应用程序。
标签: nlog