I have a maven web application in which I am using logback and JBoss EAP 6.1 as server. The problem is that when I deploy it on server, my logback.xml is ignored and logback's default configuration is used which prints on console instead of my log file. Logging works fine if I deploy my application on tomcat.
I have put logback.xml in src/main/resources.
Found similar question at - Logging Configuration in Logback + SL4J + JBoss EAP 6.0 and Logback and Jboss 7 - don't work together? but no use...
Forgot to share the solution earlier..here it is -
We need to add following lines in jboss-deployment-structure.xml
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.impl" />
<module name="org.apache.log4j" />
</exclusions>
So the entire file looks like -
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding
some dependencies -->
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.impl" />
<module name="org.apache.log4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
If you have a maven project, you can put this file at -
<project>/webapp/META-INF/jboss-deployment-structure.xml
Now logging will work fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With