log4j.properties doesn't work correctly on wildfly

允我心安 提交于 2020-01-04 02:42:26

问题


I have a log4j.properties file in the classpath.

It was found at the location APP/XX.jar/log4j.properties.

And I noticed that in the ear file I can also find log4j-1.2.17.jar in lib folder.

But whatever I wrote in the log4j.properties file, they were ignored. Like:

log4j.rootCategory=WARN

Or something like this:

log4j.rootCategory=INFO, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.logger.org.springframework=WARN

But all of the loggings will still be printed on the server.

Did I configure them wrong or has my Wildfly this property file igored?


回答1:


Given the location of the properties file it is ignored. If the log4j.properties file is in the EAR/META-INF directory then WildFly will attempt to configure log4j for you. It's suggested not to use a ConsoleAppender though as it could result in deadlocks due to the appender attempting to write to System.out and System.out being wrapped in WildFly.

Given the configuration this leaves you with three options.

  1. Change the value of add-logging-api-dependencies to false.
  2. Add a jboss-deployment-structure.xml and disable the logging subsystem on your deployment
  3. Configure logging via the logging subsystem. This can be done either globally or via a logging-profile.


来源:https://stackoverflow.com/questions/26488486/log4j-properties-doesnt-work-correctly-on-wildfly

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