Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4net - how to filter out exceptions which contain a specified text?

I use log4net to log exceptions, and it generally works fine. But I would like to be able to filter out exceptions which contain a specific text string.

I found this example of implementing a filter, but it does the opposite of what I want; it only includes messages with the specified string. I want to exclude the specified string.

<filter type="log4net.Filter.StringMatchFilter">
  <stringToMatch value="My Exclude String" />
</filter>

<filter type="log4net.Filter.DenyAllFilter" />

Is it possible to exclude the specified string instead?

like image 650
mrturtle Avatar asked May 27 '15 07:05

mrturtle


1 Answers

Just invert your filter in the configuration by using the acceptOnMatch property on the filter.

<filter type="log4net.Filter.StringMatchFilter">
  <stringToMatch value="My Exclude String" />
  <acceptOnMatch value="false" />
</filter>
like image 101
samy Avatar answered Sep 28 '22 09:09

samy