-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traditional war deployment in standalone tomcat does not output logging when server is shutting down #27996
Comments
Thanks for the report but I can't reproduce the 10 second pause that you have described. I used Tomcat 9.0.53 which produced the following log output:
The acceptor thread taking in excess of 10 seconds to stop doesn't feel to me like it's related to Spring Boot as it has no control of Tomcat at this level. The logging problem may be related to #9457, although we thought that only affected JUL-based logging and you're using SLF4J and Logback. Regardless, I'm reluctant to spend time debugging it until we can reproduce the same behaviour as you have described. |
The logging problem happens to SLF4J and Log4j2 also. I will take some time to investigate the 10 seconds problem. |
Title updated to be more precise. I confirm the 10 seconds problem is not related to spring boot, It's gone when I disable my system proxy. |
The logging problem does not occur when run using
|
Yes, it only occurs in traditional war deployment, I guess |
When the application is undeployed, Logback's |
Actually I'm using Log4j2 instead of Logback, please make sure both logging system work properly. |
The sample that you provided uses Logback. Why provide a sample for one logging system when you are, in fact, using another? |
My real application is using Log4j2, I reproduce it by a simple example which original using Log4j2 too, I changed it to spring default to keep the example minimal. Anyway, my point is this problem exists with both Log4j2 and Logback. |
Unfortunately, that resulted in wasting a significant amount of my time. Your Logback-based example was incorrectly configured as it was registering its own While we appreciate a sample being as minimal as possible, in the future please ensure that it accurately reproduces your own setup. |
@wilkinsona , I'm sorry, I thought it will save your time, unfortunately things go athwart. |
I can confirm that a4f1d32 fixed for Log4j2, and Logback still doesn't works properly. |
Logback worked correctly in my testing. Have you disabled its servlet container initializer as I described above? |
Using CATALINA_OPTS: -Duser.country=US
|
@wilkinsona Logback works properly with a4f1d32 and explicit |
If I don't want the Logback ServletContainerInitializer to be instantiated by my Spring Boot application, is there a way to specifiy that in the Spring Boot configuration? (Or the only way to do that is by using |
@sorin-postelnicu Please see the comment above that lists your options for disabling the initializer. |
@wilkinsona Thank you for the answer. I asked the question here since I thought it's relevant to the subject. Therefore, if I understood correctly, your answer is that there is no option to disable it via Spring Boot config; the only options available are the 2 options provided in the logback documentation. |
In case someone else will encounter this issue and to avoid spending a few days trying to configure this, I paste here the solution I finally found for configuring logback in a custom
|
example.zip is a very simple project, I deployed it to standalone tomcat refer to https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.traditional-deployment
There are 2 problems:
@PreDestroy
is not output because log system is shutdown too early byLoggingApplicationListener::onContextClosedEvent
The text was updated successfully, but these errors were encountered: