How to globally enable debug
for all the slf4j.Logger
objects?
Just add the following to the application.properties
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.context=DEBUG
Programmatically, with logback:
setLoggingLevel(ch.qos.logback.classic.Level.DEBUG);
where
public static void setLoggingLevel(ch.qos.logback.classic.Level level) {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
root.setLevel(level);
}
If you use log4j as the binding of slf4j you can crete a log4j.xml (or log4j.properties) file and add it to the classpath. An example could be:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<param name="Threshold" value="DEBUG" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n" />
</layout>
</appender>
<root>
<appender-ref ref="CONSOLE" />
</root>
</log4j:configuration>