Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback not working with JBoss EAP 6.1

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...

like image 574
N.. Avatar asked Dec 07 '13 18:12

N..


1 Answers

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.

like image 128
N.. Avatar answered Oct 08 '22 23:10

N..