I am fixing a legacy JSF application running on tomcat 7.
UserAccessBB.java
package beans;
import java.util.logging.Level;
import java.util.logging.Logger;
public class UserAccessBB {
private static final Logger LOG =
Logger.getLogger(UserAccessBB.class.getName());
public UserAccessBB() {
LOG.fine("UserAccessBB");
logback.xml
<logger name="beans" level="TRACE" additivity="false">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
maven
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.20</version>
</dependency>
The file is copied to WEB-INF/classes
The log file contains only INFO and higher level logs from this class. Lower levels are printed only when I modify the root logger. Where is the issue?
For future reference and googlers:
To Logback be able to propagate its configuration to JUL (java.util.logging) it is neccessary to add
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<!-- reset all previous level configurations of all j.u.l. loggers -->
<resetJUL>true</resetJUL>
</contextListener>
and use the current version. Cudos to @vanOekel. See https://stackoverflow.com/a/20407321/1639556 for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With