在 jboss 6 下使用我的 log4j [英] Use my log4j under jboss 6
问题描述
我想在 JBOSS6 上部署我的 Web 应用程序.应用程序本身有效,但日志记录无效.我使用 log4j 并在我的战争中添加了一个 jboss-deployment-structure.xml.内容是
I want to deploy my web application on JBOSS6. The applicaation itself works, but the logging doens't. I use log4j and have added a jboss-deployment-structure.xml to my war. The contents are
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
</exclusions>
</deployment>
在我的 log4j.xml 中有
In my log4j.xml I have
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "dtd/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="LogAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="C:\logs\web.log"/>
<param name="MaxFileSize" value="10000KB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%x %-5p [%d{yyyyMMdd HH:mm:ss}] - %c:%L - %m%n"/>
</layout>
</appender>
<logger name="be.sofico.web">
<level value="debug" />
<appender-ref ref="LogAppender" />
</logger>
这一切在 tomcat 和 websphere 上都可以正常工作(当我最后设置类加载父级时)
This all works fine on tomcat and websphere (when I set classloading parent last)
如何让它在 JBOSS 6 上运行?
How can I get it to work on JBOSS 6?
推荐答案
我通过以下方式解决了我的问题:将 jboss-deployment-structure.xml 放在 webMETA-INF 中,文件中包含以下内容
I solved my problem doing the following: put jboss-deployment-structure.xml inside webMETA-INF with the following in the file
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
</exclusions>
</deployment>
</jboss-deployment-structure>
并将其添加到服务器的启动中:-Dorg.jboss.as.logging.per-deployment=false
And add this to the startup of the server: -Dorg.jboss.as.logging.per-deployment=false
这篇关于在 jboss 6 下使用我的 log4j的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!