2

Looking the way how to configure slf4j in Spring boot app:

I add this in my application.properties:

logging.level.org.springframework.web=DEBUG
logging.file=book.log
logging.level.*=DEBUG

I have this controller:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Controller
@RequestMapping("/book")
public class BookController {

    private static final Logger logger = LoggerFactory.getLogger(BookController.class);

@RequestMapping(value={ "/list"}, method = { RequestMethod.GET})
    public String bookList(Model model, HttpServletRequest request) throws DataAccessException, SQLException {

        logger.debug("testing...");

}
}

But my message is not logged in the file, but there are other messages:

...
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'multipartConfigElement': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'multipartResolver': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'spring.http.multipart-org.springframework.boot.autoconfigure.web.MultipartProperties': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'serverProperties': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'duplicateServerPropertiesDetector': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration$RestTemplateConfiguration': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'restTemplateBuilder': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration$RestartConfiguration': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'classPathFileSystemWatcher': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'classPathRestartStrategy': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'hateoasObjenesisCacheDisabler': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'fileSystemWatcherFactory': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration$LiveReloadConfiguration': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'liveReloadServer': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'optionalLiveReloadServer': no URL paths identified
2017-03-26 08:13:49.768 DEBUG 2426 --- [restartedMain] o.s.w.s.h.BeanNameUrlHandlerMapping      : Rejected bean name 'org.springframework.boot.devtools.autoconfigure.
...
en Lopes
  • 1,863
  • 11
  • 48
  • 90

2 Answers2

0

Try using

logging.level.*=DEBUG

When you are specifying package name with logging level it will work for that package only. Either you can define root logger or use * for all packages.

Monzurul Shimul
  • 8,132
  • 2
  • 28
  • 42
0

Even I faced this issue, adding logging.level.*=DEBUG didn't helped.

You can try this:

  1. logging.level.root = DEBUG

  2. logging.level.package_name=DEBUG Example: logging.level.com.example.controller=DEBUG

Rakesh
  • 1,374
  • 1
  • 16
  • 24