I have the following loggers configured.
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File" fileName="trace.log"/>
<target name="trace" xsi:type="OutputDebugString"/>
<target name="console" xsi:type="ColoredConsole" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="file" />
<logger name="*" minlevel="Info" writeTo="trace" />
<logger name="*" minlevel="Info" writeTo="console" />
</rules>
</nlog>
I want everything for Component.* to only be logged from WARN and higher for all loggers. With NHibernate, this is easy:
<logger name="NHibernate.SQL">
<level value="OFF"/>
</logger>
I tried to add the following:
<logger name="Component.*" minlevel="Warn" final="true" />
This doesn't work.
How do I only log from a certain level for a logger namespace for all targets?
The solution is:
<logger name="Component.*" maxlevel="Info" final="true" />
You basically say, for logger(s) X, I want to skip all log entries that match Info or lower as this does not have the writeTo
attribute.
It is documented here:
https://github.com/nlog/NLog/wiki/Configuration-file
With the sample:
<logger name="Name.Space.*" minlevel="Debug" maxlevel="Error" final="true" />