Reputation: 2305
I can't get this to work. I've also tried the --debug
option in IntelliJ. It's always printing "debug is not enabled" and never printing my .debug() messages to console. Any ideas?
the .java file
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MyClass {
private final Logger logger = LoggerFactory.getLogger(MyClass.class);
public void myMethod() {
if (logger.isDebugEnabled()) {
logger.info("debug is enabled");
}
else {
logger.info("debug is not enabled");
}
logger.debug("\n\ntest debug message\n\n");
}
src/main/resources/log4j.properties
log4j.rootLogger=debug, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.logger.com.mycompany=debug
I tried updating my application.yml to set the logging level but it had no effect:
application.yml
logging:
level:
root: DEBUG
org.springframework.web: DEBUG
guru.springframework.controllers: DEBUG
org.hibernate: DEBUG
Upvotes: 1
Views: 2755
Reputation: 2305
I figured it out. After poking around SO more, I updated my config file to set the logging level as follows:
/src/main/resources/application.yml
logging:
level:
ROOT: DEBUG
(note: indent level matters! It would only work when it was at the very top level of the .yml file, i.e. no indents)
Upvotes: 4