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?
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With