Migrating from log4j 1.2 to log4j 2: LevelRangeFilter

Deadly 提交于 2019-12-10 17:22:12

问题


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>

回答1:


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>


来源:https://stackoverflow.com/questions/24932539/migrating-from-log4j-1-2-to-log4j-2-levelrangefilter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!