I'm using Nlog for years to ... log details and exceptions from an application.
The NLog.config file is unchanged for years and it looks as below
<nlog>
<targets>
<target xsi:type="File" name="f"
fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}${onexception:inner=${newline}${exception:format=tostring}}" />
<target xsi:type="File" name="fe"
fileName="${basedir}/logs/${shortdate}_err.log"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}${onexception:inner=${newline}${exception:format=tostring}}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" maxlevel="Warn" writeTo="f" >
<filters>
<when condition="contains('${message}','[HTTPS]')" action="Ignore"/>
<when condition="contains('${message}','[EmailCachingHelper]')" action="Ignore"/>
</filters>
</logger>
<logger name="*" minlevel="Error" writeTo="fe" ></logger>
</rules>
</nlog>
The problem is, since a while, about two weeks ago, the f log file is no longer created. The exceptions log file, fe, *_err.log is still created ok.
In that date I updated Nlog from 4.7.15 to 5.0.0
Does anyone know what could cause this? Is there any additional config setting I need to do?
Thank you
After some research I found a breaking change in config from 4.x to 5.x
The LoggingRule Filters DefaultAction was changed from Neutral
to Ignore
.
This means NO output, if using dynamic filters and not already using defaulAction="Ignore"
.
The fix was to add DefaultAction to Log
<filters defaultAction="Log">
which fixed the problem