Log4J: Strategies for creating Logger instances

后端 未结 10 621
不思量自难忘°
不思量自难忘° 2020-11-30 21:22

I decided to use Log4J logging framework for a new Java project. I am wondering what strategy should I use for creating/managing Logger instances and why?

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 21:51

    When deploying multiple EARs / WARs, it may be better to package the log4j.jar higher up in the classloader hierarchy.
    i.e. not in WAR or EAR, but in the System-classloader of your container, otherwise multiple Log4J instances will write to the same file concurrently leading to strange behaviour.

提交回复
热议问题