spring-bootloggingbannertomcat9

Spring banner is not printed within log


Within my Spring Boot application (loglevel=DEBUG) I do log against slf4j, jcl (commons logging), log4j and jul (java util logging). I do use following:

Running it on Tomcat (juli) it doesnt print the Spring Boot bannner.

We are using Tomcat with a Logging Bridge. This Logging Bridge contains a LoggingListener (that implments the org.apache.catalina.LifecycleListener) and does redirect every Log from System.out and System.err.

systemOut = System.out;
systemErr = System.err;

System.setOut(new PrintStream(new LoggingOutputStream(Level.DEBUG, systemOut), true));
System.setErr(new PrintStream(new LoggingOutputStream(Level.WARN, systemErr), true));

The execution of this code snipped is based on a class attribute flag (private boolean redirectSystemLogs) which is always true - I tried to steer this flag from outside (tomcat clathpath) but didnt succeed. And still I would expect that with loglevel DEBUG I should be able to see the spring banner in the logs.


Solution

  • You have to tell it to print to the log file and not the console. In your application.yml:

    spring:
      main:
        banner-mode: log
    

    https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/Banner.Mode.html