I've been troubleshooting this error for hours now, so I decided to ask it on Stackoverflow. For a project I need to add logging, and I chose Logback due to its functionality.
I added logback-classic and logback-access (for TomEE) to my pom.xml and added logging statements to a class to test it out. In my console, I can see that there are events being logged, but they don't get written to a .log file. This likely indicates that TomEE uses the default Logback configuration, and not the one I set up as follows (under resources/WEB-INF/classes/logback.xml):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>myApp-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="FILE"/>
</root>
</configuration>
If I run my Maven unit tests, Maven seems to pick up this configuration and Logback correctly writes some events to the log file. But if I launch my Artifact on IntelliJ, nothing seems to happen (it only prints events to the console, but not to a log file). I am not sure where the issue lies here, it could be either IntelliJ or TomEE. I hope someone can lend me a hand here.
- I tried adding -Dlogback.configurationFile= to the VM options in IntelliJ
- I checked the target directory and it shows the logback.xml in its correct place:
- I've reimported the project in IntelliJ by removing the .idea folder
- I've updated tomEE and IntelliJ