如何使用Jboss AS 7.1启用自定义log4j [英] How to enable a custom log4j with Jboss AS 7.1

查看:73
本文介绍了如何使用Jboss AS 7.1启用自定义log4j的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried several options. But anything didn't work for me. Previously I used the same log4j.xml (simple common config) with Tomcat 6,7 and I could able to control the root logging and the application logging with updating the log4j.xml. When I deploy the same project with JBoss AS 7.1, It only gives me INFO level logging and my log4j.xml doesn't work at all. Sometime this can be fixed by updating some configuration files inside the JBoss server, but I like to know if there a portable way to do it or something similar. If this is bug or something with JBoss AS 7.1 I like to know about a quick fix anyway. I haven't worked with JBoss before.

谢谢!

推荐答案

我遇到了此问题,并通过以下方法解决了该问题:
使用您自己的log4j jar,而不是jboss提供的jar.通过从应用程序中排除jboss org.apache.log4j jar模块(在jboss-deployment-structure.xml中排除它)并在.ear软件包的lib文件夹中添加自己的log4j jar文件来实现. 现在将log4j.xml放入模块的根文件夹中.
通过这种方法,您可以完全控制log4j(例如独立应用程序).
让我知道您是否需要更多帮助.

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.

示例jboss-deployment-structure.xml排除log4j.jar:

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>

这篇关于如何使用Jboss AS 7.1启用自定义log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆