log4j.properties在Wildfly上无法正常工作 [英] log4j.properties doesn't work correctly on wildfly
问题描述
我在类路径中有一个log4j.properties文件.
I have a log4j.properties file in the classpath.
在位置APP/XX.jar/log4j.properties中找到它.
It was found at the location APP/XX.jar/log4j.properties.
我注意到在ear文件中,我还可以在lib文件夹中找到log4j-1.2.17.jar.
And I noticed that in the ear file I can also find log4j-1.2.17.jar in lib folder.
但是无论我在log4j.properties文件中写什么,它们都会被忽略.喜欢:
But whatever I wrote in the log4j.properties file, they were ignored. Like:
log4j.rootCategory=WARN
或者类似这样的东西:
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.
我配置错误吗?还是我的Wildfly这个属性文件被欺骗了?
Did I configure them wrong or has my Wildfly this property file igored?
推荐答案
给出属性文件的位置,将其忽略.如果log4j.properties文件位于EAR/META-INF
目录中,则WildFly将尝试为您配置log4j.建议不要使用ConsoleAppender
,因为由于附加器试图写入System.out
且System.out
被包装在WildFly中而可能导致死锁.
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.
- 更改>
add-logging-api-dependencies
到false
. - 添加
jboss-deployment-structure.xml
并在部署中禁用日志子系统 - 通过日志记录子系统配置日志记录.可以全局或通过 logging-profile .
- Change the value of
add-logging-api-dependencies
tofalse
. - Add a
jboss-deployment-structure.xml
and disable the logging subsystem on your deployment - Configure logging via the logging subsystem. This can be done either globally or via a logging-profile.
这篇关于log4j.properties在Wildfly上无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!