log4j用properties文件配置,无法应用过滤器的解决方法

properties文件仍然有错误

log4j:WARN Failed to set property [filter] to value "org.apache.log4j.varia.LevelRangeFilter". 
log4j:ERROR Could not instantiate class [FATAL].

后来我在国外论坛上找到了答案

The PropertyConfigurator does not handle the advanced configuration features supported by the DOMConfigurator such as support for Filters, custom ErrorHandlers, nested appenders such as the AsyncAppender, etc.

 

翻译如下:

PropertyConfigurator 不能处理那些DOMConfigurator支持的高级配置功能,例如过滤器支持、自定义错误处理器、嵌套Appender(例如AsyncAppender)等等

 

看来xml配置才是log4j的王道。果然换了xml配置就可以使用了。

参考地址:http://stackoverflow.com/questions/1257641/cant-set-levelrangefilter-for-log4j

posted @ 2016-08-01 13:24  这个名字想了很久~  阅读(1748)  评论(0编辑  收藏  举报