gpt4 book ai didi

log4j - 在 JBoss 7.1 中使用 log4j

转载 作者:行者123 更新时间:2023-12-03 21:24:24 25 4
gpt4 key购买 nike

如何在 JBoss 7.1 中使用 log4j?

我的 WebContent/WEB-INF/lib 文件夹中有一个 log4j-1.2.16.jar。当我输出 Logger.getRootLogger().getClass().toString() 的结果时我收到 class org.jboss.logmanager.log4j.BridgeLogger这是错误的。

如果我添加 Dependencies: org.apache.commons.logging到我的 MANIFEST.MF 文件,我得到了相同的结果。

这导致了我的 log4j.properties 文件(我在 WEB-INF/classes 下创建的)被忽略的问题。

最佳答案

很快就会有一种方式,will just work for you ,但目前您必须从部署中排除 log4j 依赖项。您还必须手动调用 PropertyConfigurator.configure() 来加载属性文件。

以下文件 ( jboss-deployment-structure.xml ) 需要包含以下内容:

<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>

然后在 WEB-INF/lib 中添加包含您自己的 log4j 版本目录应该像您期望的那样工作。

关于log4j - 在 JBoss 7.1 中使用 log4j,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9584787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com