Spring boot embedded tomcat logs

embedded-tomcat-8loggingspringspring-boottomcat8

i'm using spring boot embedded tomcat with spring boot 1.5.9 ,
im also using Log4j2.

recently i exerience problems during load, so i want to understand better the tomcat logs [Not the access Logs] , i tried (in application.properties) :

logging.level.org.apache.tomcat: INFO
logging.level.org.apache.catalina: INFO

but none of the above worked. is there any other way to achieve it ?

Best Answer

Found it !! You are now able to see the internal Logs of Embedded Tomcat in your App's Log4j log file with 3 easy steps:

1] add to your pom:

 <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-jul</artifactId>
     </dependency>

2] add to your running arg a new JVM param , e.g:

java -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -jar target/demo-0.0.1-SNAPSHOT.jar

3] add to your application.properties:

logging.level.org.apache=DEBUG

Enjoy Life ! :)

Explaination: the problem is because Log4j log levels is not propagated into JUL (which is the actual Logging way Embedded tomcat use) so the above achieves this connection with JUL and Log4j log levels.

Reference: After reading the Spring boot 1.5.10 release notes (which is not required for the solution) i saw the new documentation that shed light how to achive it and explaination about it:

https://github.com/spring-projects/spring-boot/issues/2923#issuecomment-358451260