I am working with Spring (Core/Security/ldap and more), and logback. But for some reason spring does not receive the loggin threshhold set in the logback XML I can see that as well when i debug springs source code and i see that the
final boolean debug = logger.isDebugEnabled();
Is false
As well i would like to mention (I don't know if it has any relevance) that the logger that spring uses is:
org.apache.commons.logging.LogFactory
org.apache.commons.logging.Log
And not SLF4j like i use
So how am i supposed to enable the debug level and bring the logs into my SLF4J configuration..
Thanks
Spring by default uses Apache's Jakarta Commons Logging library. You need to disable it and instead use the slf4j bridge. You should have the following (among others)
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
Then your logback.xml
or other configuration can set the log level. For example,
<logger name="org.springframework" level="info" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
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