How can I filter logging based on a logged exception message?
The code is as follows:
try {
someService.DoSomeWorkflow();
} catch(Exception e) {
log.Error("Hey I have an error", e);
}
The configuration looks like this:
<appender name="EventLogger" type="log4net.Appender.EventLogAppender">
<applicationName value="foo" />
<layout type="log4net.Layout.PatternLayout" value="PID:%P{pid}: %message" />
<filter type="log4net.Filter.StringMatchFilter">
<stringToMatch value="TextInsideTheException" />
</filter>
</appender>
I find that I can only filter on a registered message ("Hi, I have an error"), but it seems to ignore the exception message. Since this is in our production environment, I cannot change any code changes, so I cannot change the registered message. Is there some kind of configuration that will also point to checking the exception message?
source
share