0

I followed some articles and tried to come with the solution by following some similar SO questions but still can't make this work - my logfile is not being created anywhere I searched for it.

My goal is to have working logging bundled within the application, not use vendor specific logging. My current situation is following:

I have created jboss-deployment-structure.xml inside MyEAR/META-INF directory with 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 have created logback.xml also in MyEAR/META-INF directory and with 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 specified in 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>

This results in folder MyEAR/lib which then holds those three JAR files.

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

Is there anything I'm missing to make it work?

Kousalik
  • 3,111
  • 3
  • 24
  • 46

1 Answers1

0

You'll need to exclude the logging subsystem for each subdeployment as well. 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>
James R. Perkins
  • 16,800
  • 44
  • 60
  • Unfortunatelly no difference. I included all modules in the way you proposed, but logging still goes only into standard WildFly log (both stdout and server.log). – Kousalik Sep 01 '15 at 20:45
  • Hmm... ...I don't know a lot about logback, but it looks like it's not being configured. Maybe try just placing it in your WAR file just to see if it configures it then. I'm not sure where it looks for configuration files. – James R. Perkins Sep 01 '15 at 20:54
  • Well, it uses WildFly configuration and its logs, so I'd say these exclusions somehow don't work, cause they should disable this relation. Will try to move these across my modules like you said. – Kousalik Sep 02 '15 at 04:09
  • Excluding the logging subsystem only stops the deployment processors from running which just add dependencies, look for logging configuration files, etc. Logging should still work even if you leave the logging subsystem off. – James R. Perkins Sep 02 '15 at 14:36