Boot应用程序的默认日志文件

Boot应用程序的默认日志文件

本文介绍了Spring Boot应用程序的默认日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在spring.boot应用程序的application.yml中将日志记录级别设置为: logging.level.com.Myapplicationname =调试

I have set the logging level in the spring boot application in application.yml as: logging.level.com.Myapplicationname=DEBUG

该应用程序已打包并部署为tomcat上的war.除此之外,我还没有设置logback.xml来定义日志文件等.请告诉我,当某些用户通过浏览器使用应用程序时,在哪里可以看到控制台日志.框架是否创建了任何默认文件.

The application is packaged and deployed as war on tomcat. Apart from this I haven't set the logback.xml to define the log file etc. Please tell me where can I see the console logs when some user uses the application over the browser. Is there any default file created by framework.

推荐答案

您应该指定logging.filelogging.path,但不能同时指定两个(如果同时指定了两者,则logging.path将被忽略,而仅考虑logging.file.

You should either specify logging.file or logging.path, but not both (when both are specified, logging.path is ignored and only logging.file is considered).

1.使用logging.file

您可以使用以下任一方法使用logging.file:

You may use logging.file one of the following way:

logging.file = logfile.log                     //in current folder
logging.file = relativepath/to/logfile.log     //relative path with filename
logging.file = /fullpath/to/logfile.log        //full path with filename

Spring Boot文档:

Spring Boot的文档记录方法中,:

2.使用logging.path

您还可以使用logging.path设置路径,在这种情况下,日志文件将自动命名为spring.log:

You could also use logging.path to set the path, in which case the logfile will automatically be be named spring.log:

logging.path = ./                         // -> spring.log in current folder
logging.path = relativepath/to/logs       // -> relativepath/to/logs/spring.log
logging.path = /fullpath/to/logs          // -> /fullpath/to/logs/spring.log

Spring Boot文档:

Spring Boot日志中的springframework.guru :

这篇关于Spring Boot应用程序的默认日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 20:40