I'm using log4net to log my web app's progress, using Log4PostSharp to AOP-injectify all methods. This has the desired effect of logging (almost) everything and is fine.
I now have a requirement to log JUST Page_Load methods to a file / console. I can obviously hamstring the log4postsharp class to do that, but then I'd be losing all the other logging.
I've been looking at filters in log4net, starting with the StringMatch filter, but that only looks at the message being logged, and I'm after the method name. This put me onto the PropertyFilter, but still with no joy. My log4net.config snippet is thus:
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<filter type="log4net.Filter.PropertyFilter">
<key value="LocationInfo.MethodName"/>
<stringToMatch value="Page_Load"/>
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<file value="d:\\xxxx\\yyyyy\\zzzzLog"/>
As you can see, I'm trying to key into the MethodName of the logging event via LocationInfo, but I'm still getting everything logged. EDIT: As mentioned in the comments, I've now included the DenyAllFilter that I added after RTFM ;-)
Can anyone assist?
Thank you,
Mike K.