-
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
Throwable from logging system initialization may result in the application silently failing to start #38885
Comments
When I add you config to an empty project I get the following output:
@Armstrong4444 Could you please provide a project (GitHub or attached zip) that replicates the problem? |
My sample project: https://github.com/Armstrong4444/spring-logback-config-issue-demo I checked it out again and found out that the issue only occurrs when I set the logback config through the application.properties file. (https://github.com/Armstrong4444/spring-logback-config-issue-demo/blob/main/src/main/resources/application.properties). When I placed the logback.xml file directly into resources inside the project it was ok. |
Sorry @Armstrong4444 but I still see the same error output with that sample when I run the application. I'm running the app from my IDE (Eclipse). How are you running your application? Is there any other configuration that could be causing the issue? |
I added some dependencies to the gradle.build file so now the only missing dependency should be org.codehaus.janino.ScriptEvaluator. One way I simulate the issue is:
My console output is:
And then the exit code 1. I checked the logback.xml file again to see if it's the same as mine, and it is. Maybe the last log message No appenders present in context [default] for logger [org.springframework.boot.SpringApplication] could be a clue? |
Thanks, @Armstrong4444, I believe I've reproduced the problem. The logback.xml that's required to reproduce the problem is simpler than the one shared above. The following is sufficient:
With this file referenced through
|
When there is an error raised during logback initialization, spring boot application crashes without displaying any message.
In my case, the error was caused by a missing gradle dependency org.codehaus.janino:janino.
Here is the content of my logback.xml file: logback.txt
Library org.codehaus.janino:janino is essential dependency for this logback config to work properly. Specifically for evaluating expressions in the EvaluatorFilter. Another essential dependencies for this config are ch.qos.logback.contrib:logback-json-classic and ch.qos.logback.contrib:logback-jackson.
I internally solved this issue by registering a custom SpringApplicationRunListener where the failed method is overridden. This method is implemented to dump the stacktrace directly into stderr. Then I can see the NoClassDefFound error as expected.
Similar issue: #10711
I think that there should be displayed some information about the reason of the crash even in this circumstances.
Thank you.
The text was updated successfully, but these errors were encountered: