Spring Boot:如何禁用启动日志消息“使用PID 99446在mbp上启动应用程序" [英] Spring Boot: How to disable startup log message "Starting Application on mbp with PID 99446"
问题描述
在应用程序启动时有一些日志消息:
There are some log messages on the application startup:
2016-11-01 10:13:49.468 INFO 99446 --- [ restartedMain] s7.Application : Starting Application on mbp with PID 99446 (/Users/serge/projects/scratches/s7/build/classes/main started by serge in /Users/serge/projects/scratches/s7)
2016-11-01 10:13:49.469 INFO 99446 --- [ restartedMain] s7.Application : No active profile set, falling back to default profiles: default
2016-11-01 10:13:52.642 INFO 99446 --- [ restartedMain] s7.Application : Started Application in 3.573 seconds (JVM running for 3.973)
如何禁用它们?我希望能够登录我的应用程序,但是我不需要这些日志消息.
How to disable them? I want to be able to log in my application, but I don't need these log messages.
我的application.properties具有以下设置:
My application.properties have these settings:
spring.main.banner-mode=off
logging.level.org.springframework=WARN
logging.level.org.apache=WARN
logging.level.org.mongodb=WARN
推荐答案
您可以通过配置SpringApplication
不记录启动信息来禁用这三个日志消息:
You can disable those three log messages by configuring your SpringApplication
not to log startup info:
new SpringApplicationBuilder(YourApplication.class)
.logStartupInfo(false)
.run(args);
或者,如果您要坚持使用基于日志级别的方法,则使用应用程序主类的记录器记录它们.从上面的输出来看,它称为s7.Application
,因此您还可以通过将以下内容添加到application.properties
来禁用消息:
Alternatively, if you want to stick with your log levels-based approach, they are logged using the logger for you application's main class. Judging by the output above, it's called s7.Application
so you can also disable the messages by adding the following to application.properties
:
logging.level.s7.Application=WARN
这篇关于Spring Boot:如何禁用启动日志消息“使用PID 99446在mbp上启动应用程序"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!