Monday, November 21, 2011

Log4net: exclude a logger

Today I face the debugging need of exclude some noisy loggers: the logging library I'm using is log4net, now with new active volunteer developers and a new fresh release, the 1.2.11 published in 2011/10/12 .

To successfully silence a logger is quite simple: just use a filter, select the logger and quite it.

<filter type="log4net.Filter.LoggerMatchFilter">
   <loggerToMatch value="Logger.To.Exclude" />
   <acceptOnMatch value="false" />

This is the way to black-list a logger or a namespace.

Warning: filters elements may only be defined as children of <appender> elements.

Click here for the configuration manual.

This one is a very good article about filters in log4net.

Happy logging! :)

No comments:

Post a Comment