How can I turn off Microsoft info level logging in nlog / .netcore ?
I still want info logging for my other loggers
I currently have:
<rules>
<logger name="Microsoft.*" minlevel="Error" writeTo="nxlog_json" />
<logger name="Microsoft.*" minlevel="Error" writeTo="human_text_file" />
<logger name="*" minlevel="Info" writeTo="nxlog_json" />
<logger name="*" minlevel="Info" writeTo="human_text_file" />
</rules>
This does not work, If i remove:
<logger name="*" minlevel="Info" writeTo="nxlog_json" />
<logger name="*" minlevel="Info" writeTo="human_text_file" />
It does work for the microsoft logging , but then removes all logging for the other loggers.
What am i missing ? I am assuming the logger name="" overrides the first entrys for Microsoft., but I don't want to have to explicitly specify my other loggers names.
Use final=true
that stops other filters processing if current filter applyed. And write "blackHole"
target to swallow messages:
<targets>
<target xsi:type="Null" name="blackHole" />
</targets>
<rules>
<logger name="Microsoft.*" minlevel="Info" writeTo="blackHole" final="true" />
<logger name="*" minlevel="Info" writeTo="nxlog_json" />
<logger name="*" minlevel="Info" writeTo="human_text_file" />
</rules>
NLog 4.5 allows one to specify an empty writeTo=""
<rules>
<logger name="Microsoft.*" minlevel="Info" writeTo="" final="true" />
<logger name="*" minlevel="Info" writeTo="nxlog_json" />
<logger name="*" minlevel="Info" writeTo="human_text_file" />
</rules>
Official wiki: https://github.com/NLog/NLog/wiki/Filtering-log-messages#routing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With