Reputation: 1021
I'm using NLog 4.7.10 in a C# console application. My Info, Error, and Warn messages appear in my log file as expected, but fatal messages never do. My code looks like:
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.");
I don't think anything in my nlog.config is causing issues:
<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>
What might filter out the fatal messages?
Upvotes: 0
Views: 403
Reputation: 1021
I had found the issue. One of our functions whose purpose was to set the log file path (given a database value) had a side effect. It also set the maxiumum log level. In this case, it was setting the maximum log level to Error.
Sorry to bother.
Upvotes: 1