Reputation: 195
I have an ear that has a war as a sub deployment. The ear file has a META-INF directory that has a jboss-ejb-client.xml file which just has a ejb-recievers element and a webscheduler.war. This war uses the commons-logging-api.jar. This application is deployed on jboss as 7.1.1.final. I want to use apache log4j for logging. So I added a jboss-deployment-structure.xml in the meta-inf directory of the ear
<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.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</deployment>
<sub-deployment name="a.war">
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
I have a commons-logging.properties file in the lib directory of the war that has the following in it,
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
log4j.configuration=/usr/share/wth/jboss/jboss-as-7.1.1/standalone/configuration/log4j.xml
Also apart from a log4j-1.2.11.jar I do not have any other logging framework jars in the lib.(like SLF4j etc). As you can see the log4j.xml is in the directory described by the property above.
the problem is when I start jboss, some application log does get written into the log file described in the log4j.xml (say /a/b/c/srv.log) , but simultaneously logs are also getting written into the default srv.log inside the jboss log directly.(jboss/standalone/log/srv.log).
What am I missing for jboss to not use its own logging and use the log4j configuration that I have provided.
Upvotes: 3
Views: 4818
Reputation: 4825
Your jboss-deployment-structure.xml should look like:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.apache.commons.logging"/>
</exclusions>
</deploymen>
<sub-deployment name="a.war">
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.apache.commons.logging"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
and you should have your own jars included within your project lib directory. For example:
EAR
|-- META-INF
| |-- jboss-deployment-structure.xml
| `-- MANIFEST.MF
|-- lib
| |-- log4j.jar
| `-- commons.logging.jar
`-- a.war
Make sure that you are deploying with the flag -Dorg.jboss.as.logging.per-deployment=false
, otherwise the logging may not work.
Example:
$ cd $JBOSS_HOME/bin
$ ./standalone.sh -Dorg.jboss.as.logging.per-deployment=false
Upvotes: 2