5

我尝试了几种选择。但任何事情都对我不起作用。以前我在 Tomcat 6,7 中使用了相同的 log4j.xml(简单通用配置),我可以通过更新 log4j.xml 来控制根日志记录和应用程序日志记录。当我使用 JBoss AS 7.1 部署同一个项目时,它只给我 INFO 级别的日志记录,而我的 log4j.xml 根本不起作用。有时这可以通过更新 JBoss 服务器中的一些配置文件来解决,但我想知道是否有可移植的方法或类似的方法。如果这是 JBoss AS 7.1 的错误或其他问题,无论如何我都想知道快速修复。我以前没有和 JBoss 合作过。

谢谢!

4

1 回答 1

3

I had this problem and solved it by following method:
use your own log4j jar instead of one that provided by jboss. Do it by excluding jboss org.apache.log4j jar module from your application (exclude it in jboss-deployment-structure.xml) and add your own log4j jar file in lib folder of the .ear package. Now put log4j.xml in the root folder of your module.
By this method you have full control on log4j (like standalone applications).
let me know if you need more help.

Sample jboss-deployment-structure.xml for excluding log4j.jar:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
    <exclusions>
        <module name="org.apache.log4j" slot="main"/>
    </exclusions>
</deployment>

 <sub-deployment name="MyEjb.jar">
    <exclusions>
        <module name="org.apache.log4j"/>
    </exclusions>
</sub-deployment>

于 2013-07-29T07:12:57.057 回答