Logging specific events to WildFly 9.0.1 FINAL (SL4J + Logback)

I have followed some articles and tried to come up with a solution by following some similar SO questions, but still cannot make this work: my log file is not generated anywhere I looked for it.

My goal is to have logs enabled in your application, not vendor specific logging. My current situation is as follows:

I created a directory jboss-deployment-structure.xml

inside MyEAR/META-INF

with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <!-- it only affects single deployment -->
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

      

Then I created logback.xml

also in the directory MyEAR/META-INF

and with the following configuration:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="TMP_FILE" class="ch.qos.logback.core.FileAppender">
        <file>app.log</file>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
    </encoder>
</appender>

<root level="TRACE">
    <appender-ref ref="TMP_FILE" />
</root>

      

My dependencies are listed in the parent POM file and look like this:

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.3</version>
    </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>

      

The result is a MyEAR / lib folder, which then contains these three JAR files.

I would like to keep this registration configuration at the EAR level, so all EJB and WAR modules can use it.

Is there something I am missing to make it work?

0


source to share


1 answer


You also need to exclude the logging subsystem for each subtask. Something like:



<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <!-- it only affects single deployment -->
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </deployment>
    <sub-deployment name="mywar.war">
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </sub-deployment>
    <sub-deployment name="myejb.jar">
        <exclude-subsystems>
            <subsystem name="logging" />
        </exclude-subsystems>
    </sub-deployment>
</jboss-deployment-structure>

      

0


source







All Articles