Last Updated: May 04, 2019
·
1.982K
· housemaister

log4j/log4cxx: log to two different files with different levels

If you want to log to two different files (works with other appenders too) with two different log levels use the LevelRangeFilter in the appender. A config will look like this:

<appender name="logfile" class="org.apache.log4j.rolling.RollingFileAppender">
    ...
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMin" value="INFO"/>
        <param name="AcceptOnMatch" value="true"/>
    </filter>
</appender>