views:

108

answers:

1

I am using log4Net in my application which also uses nHibernate. Now my eventlogger is flooded with nHibernate messages which I want to suppress.

I have tried this but it did not work.

<log4net>
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <param name="LogName" value="App Log" />
      <param name="ApplicationName" value="DataService" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
      <filter type="log4net.Filter.LoggerMatchFilter">
        <loggerToMatch value="NHibernate*" />
        <acceptOnMatch value="false" />
      </filter>
    </appender>
    <root>
      <priority value="ALL"/>
      <appender-ref ref="EventLogAppender"/>
    </root>
 </log4net>
+2  A: 

You can add a logger for nHibernate and set up a different level:

<logger name="NHibernate" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="RollingFileAppender"/>
</logger>
kgiannakakis