从log4j 1.2迁移到log4j 2:LevelRangeFilter

时间:2014-07-24 11:33:51

标签: filter log4j log4j2

以下log4j 1.2配置的log4j 2等效是什么?

<filter class="org.apache.log4j.varia.LevelRangeFilter">
    <param name="LevelMin" value="DEBUG" />
    <param name="LevelMax" value="INFO" />
</filter>

1 个答案:

答案 0 :(得分:9)

您无需创建自己的过滤器(http://bitfish.eu/java/log4j-2-multiple-appenders-with-different-log-levels/),而只需使用带有两个ThresholdFilters的复合过滤器:

<Filters>
    <ThresholdFilter level="DEBUG"/>
    <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>