且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Spring Boot应用程序中启用Spring框架的日志记录

更新时间:2022-12-18 11:29:41

默认情况下,Spring Boot启动程序包中包含SLF4j日志记录

By default, the SLF4j Logging is included in the Spring Boot starter package

要启用日志记录,必须在配置属性文件(application.properties/application.yaml)中定义日志记录级别.

To enable logging, you have to define logging level in your configuration properties file(application.properties/application.yaml).

例如:要查看控制台中的日志,请设置以下属性 logging.level.org.springframework.web = ERRORlogging.level.com =调试

For example: To see the logs in console set the following properties logging.level.org.springframework.web=ERROR logging.level.com=DEBUG

要输出日志文件,请设置以下属性

To output the logs in file, set the following properties

logging.level.org.springframework.web=ERROR
logging.level.com=DEBUG

输出到temp_folder/文件

logging.file=${java.io.tmpdir}/application.log