Search code examples
loggingspring-boot

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.

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

Solution

  • 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