问题描述
在 spring-boot
应用程序中,我可以指定一个自定义日志文件
In a spring-boot
application I can specify a custom log file with
java -jar spring-boot-app.jar --logging.file=/home/ubuntu/spring-boot-app.log
但是如果我不指定一个,它会去哪里?
But if I don't specify one, where does it go?
我在以下任何文件夹中都找不到它:
I couldn't find it in any of the following folders:
/tmp/
/var/log/
~/
我没有spring-boot-starter-logging
或任何其他日志依赖项.
I do not have spring-boot-starter-logging
or any additional logging dependencies.
我希望有类似于 catalina.out
的东西,因为默认配置运行嵌入式 Tomcat:
I was hoping to have something similar to catalina.out
since the default configuration runs an embedded Tomcat:
INFO 10374 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8100 (http)
推荐答案
Spring Boot 使用 Commons Logging 进行所有内部日志记录,但保持底层日志实现开放.
Spring Boot uses Commons Logging for all internal logging, but leaves the underlying log implementation open.
为 Java Util Logging、Log4J、Log4J2 和 Logback 提供了默认配置.在每种情况下,记录器都预配置为使用控制台输出,还提供可选的文件输出.
Default configurations are provided for Java Util Logging, Log4J, Log4J2 and Logback. In each case loggers are pre-configured to use console output with optional file output also available.
默认日志配置将在写入消息时将消息回显到控制台.因此,除非您按照描述明确指定文件,否则它会一直保留在控制台中.
The default log configuration will echo messages to the console as they are written.So until you explicitly specify a file as you described, it stays in the Console.
这篇关于spring-boot 默认日志位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!