Configuring Logging
After a long configuration recipe on building a Spring 5 MVC application, let us discuss how to enable logging using Spring Boot 2.0
Getting started
Open ch09 again and create and add the following @Controller that utilizes thread pools generated by TaskExecutor.
How to do it...
If logging and auditing can be enabled in a ground-up Spring 5 application, it is easier to integrate a logging mechanism in Spring Boot. Follow these steps:
- Create the following packages that will be utilized in the succeeding recipes:
org.packt.spring.boot.controllerorg.packt.spring.boot.daoorg.packt.spring.boot.service
- Since Spring Boot 2.0 directly supports
LogbackandSL4Jwith fewer configurations, create the followinglogback.xmlinsidesrc/main/resources. Assign a separate logger to each package above wherein each has its ownLevelvalue. Also, utilize two appenders, namelych.qos.logback.core.ConsoleAppenderto log all the messages in Tomcat'sstdout.logandch.qos.logback.core.FileAppender...