log4j.properties vs log4j.xml

前端 未结 2 1093
甜味超标
甜味超标 2020-12-23 18:04

I was asked to move from properties style configuration to xml style. The process itself is straightforward and it is not causing me any trouble, I was simply curious why I

相关标签:
2条回答
  • 2020-12-23 18:11

    Have a look at the JavaDoc. The documentation of the PropertyConfiguratorClass (log4j.properties) points out that

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

    So the DOMConfigurator (log4j.xml) offers advanced options.

    Beside that you can have (at least a simple) validity check of log4j.xml files using the provided log4j.dtd.

    If youd do not make use of the advanced features it is needless to change from properties to xml files.

    What you really should think about is to change from log4j to log4j 2 beta or even slf4j. Development of log4j has stopped and the founder of it (@Ceki) invented slf4j.

    0 讨论(0)
  • 2020-12-23 18:12

    As per FrVaBe's answer, the PropertyConfigurator class does not handle the advanced features that XML can support.

    It's worth noting one of the more useful advanced options (only available log4j.xml) is the ability to filter on a specific log level or range of log levels using LevelMatchFilter and DenyAllFilter

    A good example can be seen here.

    0 讨论(0)
提交回复
热议问题