Read the doc before diving, log4net on demand

My boss gave me a task, creating something like log-on-demand feature in our apps.


  1. Be able to define a global threshold for all classes to log.
  2. Be able to add some exception classes with threshold override the predefined global one.

As usually, I google, tried, iisreset, re-try… filter, chained, …

It turns out this is a STANDARD out-of-box feature from log4net, and I actually have been used this since day 1, to control the NHibernate logger threshold in our app.

 	    <level value="INFO" />
 	    <appender-ref ref="AdoNetAppender" />
 	  <logger name="NHibernate">
 	    <level value="ERROR"/>
 	  <logger name="OneProblemClass">
 	    <level value="DEBUG"/>

See logger section from official log4net configuration doc.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s