I'm logging all SQL generated by nHibernate because we have a weird issue. This alone generates huge logs so I'm trying to shorten them up a bit by trying to only log lines that contain a certain ID. It still seems like everything is coming through. Does anything look weird here?
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="nHibernate.txt" />
<param name="AppendToFile" value="true" />
<param name="DatePattern" value="yyyy.MM.dd" />
<layout type="log4net.Layout.PatternLayout,log4net">
<conversionPattern value="%d %p %m%n" />
</layout>
<filter type="log4net.Filter.StringMatchFilter">
<stringToMatch value="5764" />
<acceptOnMatch value="true" />
</filter>
</appender>
<logger name="NHibernate.SQL" additivity="false">
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</logger>
It turns out you need to add this code:
<filter type="log4net.Filter.DenyAllFilter" />
The full block looks like this:
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="nHibernate.txt" />
<param name="AppendToFile" value="true" />
<param name="DatePattern" value="yyyy.MM.dd" />
<layout type="log4net.Layout.PatternLayout,log4net">
<conversionPattern value="%d %p %m%n" />
</layout>
<filter type="log4net.Filter.StringMatchFilter">
<stringToMatch value="5764" />
<acceptOnMatch value="true" />
</filter>
<!-- need this here! -->
<filter type="log4net.Filter.DenyAllFilter" />
</appender>
<logger name="NHibernate.SQL" additivity="false">
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</logger>