在JBoss 7.1中使用log4j [英] Using log4j with JBoss 7.1

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

问题描述

如何在JBoss 7.1中使用log4j?

How can I use log4j with JBoss 7.1?

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

I have a log4j-1.2.16.jar in my WebContent/WEB-INF/lib folder. When I output the result of Logger.getRootLogger().getClass().toString() I get class org.jboss.logmanager.log4j.BridgeLogger which is wrong.

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

If I add Dependencies: org.apache.commons.logging to my MANIFEST.MF file I get the same result.

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

This results into the problem that my log4j.properties file (which I created unter WEB-INF/classes) is ignored.

推荐答案

不久将有一种解决方案您,但是目前您必须从部署中排除log4j依赖项.您还必须手动调用PropertyConfigurator.configure()来加载属性文件.

There will soon be a way that will just work for you, but currently you have to exclude the log4j dependency from your deployment. You will also have to manually invoke the PropertyConfigurator.configure() to load the properties file.

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

The following file (jboss-deployment-structure.xml) needs to contain the following:

<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的内容应该可以正常工作.

Then adding including your own version of log4j in the WEB-INF/lib directory should work as you expect it to.

这篇关于在JBoss 7.1中使用log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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