Spring Boot: How to disable startup log message “Starting Application on mbp with PID 99446”

匿名 (未验证) 提交于 2019-12-03 01:38:01

问题:

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.

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 

回答1:

You can disable those three log messages by configuring your SpringApplication not to log startup info:

        new SpringApplicationBuilder(YourApplication.class)                .logStartupInfo(false)                .run(args); 

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!