Published 01 Sep, 2022

Java - slf4j logger is not printing the log in console for springboot if wrapped under log.isDebugEnabled()

Category Java
Modified : Sep 29, 2022

I am using slf4j logger in my controller class, even though my has the following entries:

#logging.level.*= DEBUG*=DEBUG

The code looks like :

 private static final Logger LOGGER = LoggerFactory.getLogger(EventControllerV1.class);

public ResponseEntity<List<EventView>> requestEvents(@RequestParam("user_name") String userName) throws Exception { 
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("EventControllerV1:::requestEvents:::Parameters>>::userName::" + userName);
    return new ResponseEntity<>(eventManager.findEvents(userName), HttpStatus.OK);


In the background slf4j uses Logback framework, but still I am not able to get the console output..but if I remove the condition and use"xxx") only , I can see the output in console when I hit the endpoint


There are 2 suggested solutions here and each one has been listed below with a detailed description. The following topics have been covered briefly such as Java, Logging, Spring, Spring Boot, Slf4j. These have been categorized in sections for a clear and precise explanation.

if(log.isDebugEnabled()){"xxx") ;

Doesn't make much sense.

instead, it should be

  log.debug("xxx") ;

And to answer your original question,

this is not working

if(log.isDebugEnabled()){"xxx") ;

and this is working"xxx") ;

then that means, Log level for that class and method is at INFO level (which is higher than DEBUG). Try removing the * from*=DEBUG


Inside "src/main/resources/" file, add this:

So for example:

If you want it all, then try

The ".com" part refers to anything inside src/main/java/com. So for my project, I have src/main/java/com/yourbusiness