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:

download

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


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

1 comment:

  1. This is WAY easier to use than NHibernate:
    https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx

    ReplyDelete

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