Difference in log4net between threshold and evaluator

In log4net configuration you can filter out event by level in almost any appender, since it is supported by the AppenderSkeleton, the base class for every appender.

1
2
3
4
5
6
7
<appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
    <file value="Logs/exception.txt" />
    <appendToFile value="true" />
    <maximumFileSize value="10000KB" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="5" />
    <threshold value="ERROR"/>

Sometimes I see different configuration that uses an evaluator.

1
2
3
<evaluator type="log4net.Core.LevelEvaluator">
    <threshold value="ERROR"/>
</evaluator>

If you think that this is the same as before you are wrong. This setting is supported by all appenders that inherit from BufferingAppenderSkeleton, basically the above configuration tells the buffered appender to flush the buffer if an error of level ERROR is logged, this is expecially useful to have an immediate log of errors of the application.

Alk.

Tags: Log4Net