Rob*_*ide 13 logging spring tomcat8 spring-boot embedded-tomcat-8
我正在使用spring boot嵌入式tomcat和spring boot 1.5.9,我也使用Log4j2.
最近我加载期间的exerience问题,所以我想更好地了解tomcat日志[不是访问日志],我试过(在application.properties中):
logging.level.org.apache.tomcat: INFO
logging.level.org.apache.catalina: INFO
Run Code Online (Sandbox Code Playgroud)
但上述都没有奏效.有没有其他方法来实现它?
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>
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
3] add to your application.properties:
logging.level.org.apache=DEBUG
Run Code Online (Sandbox Code Playgroud)
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
| 归档时间: |
|
| 查看次数: |
21741 次 |
| 最近记录: |