Commit e9eae2cc authored by Jean de Klerk's avatar Jean de Klerk Committed by Phillip Webb

Log exception before sending to listeners

Change SpringApplication exception handling to log details before calling
the SpringApplicationRunListeners. Prior to this commit it wasn't possible
for a listener to shutdown logging.

Fixes gh-4680
Closes gh-4686
parent 80b30501
...@@ -819,6 +819,10 @@ public class SpringApplication { ...@@ -819,6 +819,10 @@ public class SpringApplication {
private void handleRunFailure(ConfigurableApplicationContext context, private void handleRunFailure(ConfigurableApplicationContext context,
SpringApplicationRunListeners listeners, Throwable exception) { SpringApplicationRunListeners listeners, Throwable exception) {
if (this.log.isErrorEnabled()) {
this.log.error("Application startup failed", exception);
registerLoggedException(exception);
}
try { try {
try { try {
listeners.finished(context, exception); listeners.finished(context, exception);
...@@ -832,10 +836,6 @@ public class SpringApplication { ...@@ -832,10 +836,6 @@ public class SpringApplication {
catch (Exception ex) { catch (Exception ex) {
this.log.warn("Unable to close ApplicationContext", ex); this.log.warn("Unable to close ApplicationContext", ex);
} }
if (this.log.isErrorEnabled()) {
this.log.error("Application startup failed", exception);
registerLoggedException(exception);
}
ReflectionUtils.rethrowRuntimeException(exception); ReflectionUtils.rethrowRuntimeException(exception);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment