javalogbackjava.util.logging

Logback does not log JUL fine level


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?


Solution

  • For future reference and googlers:

    To Logback be able to propagate its configuration to JCL (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.