Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating from log4j 1.2 to log4j 2: LevelRangeFilter

What is the log4j 2 equivalent of the following log4j 1.2 configuration?

<filter class="org.apache.log4j.varia.LevelRangeFilter">
    <param name="LevelMin" value="DEBUG" />
    <param name="LevelMax" value="INFO" />
</filter>
like image 328
Ogmios Avatar asked Jul 24 '14 11:07

Ogmios


2 Answers

We can use below Filter.

<LevelRangeFilter minLevel="DEBUG" maxLevel="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
like image 36
Sandip Jangra Avatar answered Nov 30 '22 20:11

Sandip Jangra


Instead of having to create your own filter (http://bitfish.eu/java/log4j-2-multiple-appenders-with-different-log-levels/) you can simply use a composite filter with two ThresholdFilters:

<Filters>
    <ThresholdFilter level="DEBUG"/>
    <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
like image 144
Ogmios Avatar answered Nov 30 '22 20:11

Ogmios