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>开发者_如何学Python
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="EventLogAppender"/>
</root>
</log4net>
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>
you should use
<loggerToMatch value="NHibernate.*" /> or <loggerToMatch value="NHibernate" />
not
<loggerToMatch value="NHibernate*" />
you can find details in regex rules
精彩评论