原文地址:https://developer.jboss.org/thread/219871?tstart=0
最近一直被jboss7 的log 苦恼了好久
普通的ejb 跟 war 包 都可以直接 搞定!
通过 在 META-INF 里面添加 jboss-deployment-structure.xml
内容 如下:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
然后就搞定了!
但是ear 呢 一直搞不定!
今天谷歌一下子就搞定了!
1:创建一个 新的 module
com
|------- xyz
|------- log4j
|------- myapp
|------- main
|------- module.xml
|------- log4j.xml
2: 将改 module 引用 到我们的ear里面
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.xyz.log4j.myapp" />
</dependencies>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j" />
<module name="org.apache.commons.logging"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</deployment>
<sub-deployment name="myapp.jar">
<dependencies>
<module name="com.xyz.log4j.myapp" />
</dependencies>
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j" />
<module name="org.apache.commons.logging"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</sub-deployment>
<sub-deployment name="myapp.war">
<dependencies>
<module name="com.xyz.log4j.myapp" />
</dependencies>
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j" />
<module name="org.apache.commons.logging"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</sub-deployment>
<sub-deployment name="myappPortal.war">
<dependencies>
<module name="com.xyz.log4j.myapp" />
</dependencies>
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j" />
<module name="org.apache.commons.logging"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
然后就搞定了!