log4j.properties在wildfly上不能正常工作。[英] log4j.properties doesn't work correctly on wildfly

本文是小编为大家收集整理的关于log4j.properties在wildfly上不能正常工作。的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在类路径中有一个log4j.properties文件.

在位置应用程序/xx.jar/log4j.properties.

找到它.

我注意到,在耳朵文件中,我也可以在lib文件夹中找到log4j-1.2.17.jar.

但是我在log4j.properties文件中写的任何内容都被忽略了.喜欢:

log4j.rootCategory=WARN

或类似的东西:

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

,但所有登录仍将在服务器上打印.

我是否将它们配置为错误或我的Wildfly这个属性文件不适合?

推荐答案

给定属性文件的位置,它被忽略了.如果log4j.properties文件在EAR/META-INF目录中,则Wildfly将尝试为您配置Log4J.建议不使用ConsoleAppender,尽管它可能导致僵局,因为该应用程序试图写入System.out和System.out被包裹在野生蝇中.

给定配置,这为您提供了三个选项.

  1. 更改禁用部署上的记录子系统
  2. 通过记录子系统配置记录.这可以在全球或通过 logge-profile "> logge-profile "> >.

本文地址:https://www.itbaoku.cn/post/1575020.html

问题描述

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?

推荐答案

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.