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?