slf4j logging with jdk – how to enable debug?
If you are using slf4j SimpleLogger implementation read this.
There you can see that simpleLogger
use INFO
as default log level. You can change it by using a system property. This is usefull for non-production evironments:
static {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "trace");
}
Why do you think it does not log DEBUG messages?
If you mean that your log.debug(String)
logging calls do not end up in java.util.logging
log files, then I guess you have to configure the logging.properties
configuration file to allow log messages at FINE
level.
If you do not want to mess with the global %JRE_HOME%/lib/logging.properties
, then you can just pass in -Djava.util.logging.config.file=logging.properties
on the command line - this will force the logging system to look for that configuration file in the current directory.
Or use some other (programmatic) way to configure java.util.logging
, see below for tutorial.
This has nothing to do with configuring SLF4J; in fact, SLF4J does not have any configuration, everything is configured by simply swapping JAR files.
For your reference:
- JDK14LoggerAdapter
- Java Logging API tutorial