I use log4net to register progress in a web application, using Log4PostSharp for AOP injection of all methods. This has the desired effect of registering (almost) everything and perfectly.
Now I have a requirement to write JUST Page_Load methods to a file / console. I can obviously block the log4postsharp class, but then I will lose all other entries.
I look at the filters in log4net, starting with the StringMatch filter, but this only looks at the message that is being logged, and I'm behind the method name. It put me on a PropertyFilter, but still without joy. So my log4net.config fragment is:
<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 am trying to enter registration events through MethodIname through LocationInfo, but I still register everything. EDIT: As mentioned in the comments, now I have included DenyAllFilter, which I added after RTFM; -)
Can anyone help?
Thanks,
Mike K.
Mike kingscott
source share