How to configure NLog to only log in from a specific level for the log namespace for * all * purposes

I have the following registrars installed.

<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. * registered only with WARN and higher for all registrars. 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 does not work.

How to register only at a certain level for the log namespace for all purposes.

+5
source share
1 answer

Decision:

 <logger name="Component.*" maxlevel="Info" final="true" /> 

You basically say: for logger (s) X, I want to skip all log entries matching Info or below, since this attribute writeTo no writeTo .

This is described here:

https://github.com/nlog/NLog/wiki/Configuration-file

With sample:

 <logger name="Name.Space.*" minlevel="Debug" maxlevel="Error" final="true" /> 
+3
source

Source: https://habr.com/ru/post/1246964/


All Articles