Slf4j is an API that sits on top of a logging framework, e.g. Log4j 2, Logback or java.util.logging. So If you want to change the log level, the best way to do this is via the configuration of your logging implementation:
- See configuration documentation for Apache Log4j 2.
- See configuration documentation for Logback.
- See Java Logging Overview for java.util.logging.
- See Log Levels Chapter for using Spring Boot properties for log level configuration.
But sometimes, especially in tests it would be nice to see some logging output without changing global configuration files. Slf4j makes this very simple, just get the logger you want to change and set the log level:
Logger restClientLogger = (Logger) LoggerFactory.getLogger(SolrRestClient.class); restClientLogger.setLevel(Level.DEBUG);
For the root logger you can use
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(Level.INFO);