Search This Blog

Thursday, September 13, 2012

log4net nhibernate stop logging to console

After using log4net and nhibernate in one project I wanted to log sql commands in a separate file. I didn't want these sql commands to appear on console either. My castle implementation of nhibernate logged either all to console and separate file or nothing.
That's the configuration I used to stop nhibenrate from logging to console and force it to log to a separate file:


The important part is to use a filter inside a ConsoleAppender:

<filter type="log4net.Filter.LoggerMatchFilter">
<LoggerToMatch value="NHibernate"/>
<acceptOnMatch value="false"/>


  1. This is WAY easier to use than NHibernate:

  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from .Net Training in Chennai. or learn thru ASP.NET Essential Training Online


If you like this post, please leave a comment :)