在应用程序启动时有一些日志消息:
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)
如何禁用它们?我希望能够登录我的应用程序,但是我不需要这些日志消息。
我的application.properties具有以下设置:
spring.main.banner-mode=off logging.level.org.springframework=WARN logging.level.org.apache=WARN logging.level.org.mongodb=WARN
您可以通过配置SpringApplication不记录启动信息来禁用这三个日志消息:
SpringApplication
new SpringApplicationBuilder(YourApplication.class) .logStartupInfo(false) .run(args);
或者,如果您要坚持基于日志级别的方法,则使用应用程序主类的记录器记录它们。从上面的输出判断,它被调用,s7.Application因此您还可以通过将以下内容添加到来禁用消息application.properties:
s7.Application
application.properties
logging.level.s7.Application=WARN