My log4net config is like this:
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="xxx" />
<from value="xxx" />
...
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="ERROR"/>
</evaluator>
<filter type="MyApp.Logging.EmailLogThrottler">
</filter>
</appender>
If I set a breakpoint in my MyApp.Logging.EmailLogThrottler
class, I see it is receiving INFO messages to filter. The EmailLogThrottler is fairly expensive so I only want it to receive ERROR messages, as per the evaluator threshold. Is this possible?
Secondary question - it seems that filters are applied first and then evaluator thresholds (which is counter intuitive to me). Is this assumption correct?
For your first question, set the threshold directly on the appender for best performance:
See this mailing list post on the difference between threshold and evaluator
What is the difference between threshold and evaluator?
Answer:
The post goes on to say this about the Evaluator, which is not intended to filter messages, but instead to trigger sending the buffered messages:
It has this to say on filters: