Spring boot internally uses Commons Logging to log logs, but also retains the external interface for some log frameworks to implement, such as Java Util logging,log4j2 and Logback. If you want to use a certain log framework for implementation, you must first configure, by default, spring boot uses logback as the framework for log implementations.
1. Configure the debug level of the console log
By default, the log level that spring boot prints from the console is only error, WARN also has info, and if you want to print debug-level logs, you can configure it through Application.properites debug=true
Debug=true
In a production environment, you can configure the debug level of the log through the command line
Java-jar C:\Users\Administrator\Desktop\xx\demo.jar--debug
3. Configure logging.level.* to specifically output which package's log level
Logging.level.root=info
logging.level.org.springframework.web=debug
logging.level.org.hibernate=error
2. Output the log to a file
Spring boot does not output the log to the log file by default, but you can output the log to a file by configuring the Logging.file file name and the Logging.path file path in the Application.properites file
Logging.path=f:\\demo
logging.file=demo.log
logging.level.root=info
Here are a few things to note: If you do not configure the specific package log level, the log file information will be empty if you configure only Logging.path, a log file will be generated in the F:\demo folder for Spring.log To configure Logging.file only, a demo.log log file will be generated under the project's current path Logging.path and Logging.file are configured simultaneously, and there will be no F:\demo\ on this path Demo.log log generation, Logging.path and logging.file do not stack Logging.path and logging.file value can be relative or absolute
This is the basic log configuration, which can be configured directly in the Application.properties, and we can also configure it under the Classpath path by defining a specific log file.