Search code examples
javaspringlogbacklogback-classic

cannot get logback TRACE logs output for my java spring application


I am trying to use logback for TRACE logging for a Spring application. However, with the configuration I have, I only get up to DEBUG logs output to the console.

Any ideas if there is some configuration that will help me get TRACE as well?
I have read several tutorials and haven't found much. This is what I have so far for configuration:

using java 19

logback.xml:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
    </appender>
    
    <root level="trace">
        <appender-ref ref="STDOUT" />
    </root>
    
    <logger name="org.springframework.security" level="trace">
        <appender-ref ref="STDOUT" />
    </logger>

</configuration>

relevant pom.xml:

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-core</artifactId>
    <version>1.5.0</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>2.1.0-alpha1</version>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.5.0</version>
</dependency>


Solution

  • I'm getting spring security trace logging with your logback.xml file. So my take is that either spring security is not doing any trace logging in your scenario, or your logback.xml is not in effect. The latter can probably be eliminated if you get debug logging for spring security on your console...