Commit 53f1488f authored by Phillip Webb's avatar Phillip Webb

Don't automatically log auto-configuration report

Update the `AutoConfigurationReportLoggingInitializer` to only output
the report at debug level. A crash report now triggers an info output
suggesting the user runs again with '--debug' to display the report.

Fixes gh-199
parent c41a3fd5
...@@ -106,7 +106,8 @@ public class AutoConfigurationReportLoggingInitializer implements ...@@ -106,7 +106,8 @@ public class AutoConfigurationReportLoggingInitializer implements
public void logAutoConfigurationReport(boolean isCrashReport) { public void logAutoConfigurationReport(boolean isCrashReport) {
if (this.report == null) { if (this.report == null) {
if (this.applicationContext == null) { if (this.applicationContext == null) {
this.logger.info("Nothing to report: ApplicationContext not available"); this.logger.info("Unable to provide auto-configuration report "
+ "due to missing ApplicationContext");
return; return;
} }
this.report = AutoConfigurationReport.get(this.applicationContext this.report = AutoConfigurationReport.get(this.applicationContext
...@@ -114,10 +115,11 @@ public class AutoConfigurationReportLoggingInitializer implements ...@@ -114,10 +115,11 @@ public class AutoConfigurationReportLoggingInitializer implements
} }
if (this.report.getConditionAndOutcomesBySource().size() > 0) { if (this.report.getConditionAndOutcomesBySource().size() > 0) {
if (isCrashReport && this.logger.isInfoEnabled()) { if (isCrashReport && this.logger.isInfoEnabled()) {
this.logger.info(getLogMessage(this.report this.logger.info("\n\nError starting ApplicationContext. "
.getConditionAndOutcomesBySource())); + "To display the auto-configuration report enabled "
+ "debug logging (start with --debug)\n\n");
} }
else if (!isCrashReport && this.logger.isDebugEnabled()) { if (this.logger.isDebugEnabled()) {
this.logger.debug(getLogMessage(this.report this.logger.debug(getLogMessage(this.report
.getConditionAndOutcomesBySource())); .getConditionAndOutcomesBySource()));
} }
......
...@@ -115,7 +115,7 @@ public class AutoConfigurationReportLoggingInitializerTests { ...@@ -115,7 +115,7 @@ public class AutoConfigurationReportLoggingInitializerTests {
} }
@Test @Test
public void logsInfoOnError() { public void logsInfoAndDebugOnError() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
this.initializer.initialize(context); this.initializer.initialize(context);
context.register(ErrorConfig.class); context.register(ErrorConfig.class);
...@@ -128,7 +128,7 @@ public class AutoConfigurationReportLoggingInitializerTests { ...@@ -128,7 +128,7 @@ public class AutoConfigurationReportLoggingInitializerTests {
new SpringApplication(), context, new String[] {}, ex)); new SpringApplication(), context, new String[] {}, ex));
} }
assertThat(this.debugLog.size(), equalTo(0)); assertThat(this.debugLog.size(), not(equalTo(0)));
assertThat(this.infoLog.size(), not(equalTo(0))); assertThat(this.infoLog.size(), not(equalTo(0)));
} }
...@@ -171,7 +171,8 @@ public class AutoConfigurationReportLoggingInitializerTests { ...@@ -171,7 +171,8 @@ public class AutoConfigurationReportLoggingInitializerTests {
this.initializer.onApplicationEvent(new SpringApplicationErrorEvent( this.initializer.onApplicationEvent(new SpringApplicationErrorEvent(
new SpringApplication(), null, new String[0], new RuntimeException( new SpringApplication(), null, new String[0], new RuntimeException(
"Planned"))); "Planned")));
assertThat(this.infoLog.get(0), containsString("Nothing to report")); assertThat(this.infoLog.get(0),
containsString("Unable to provide auto-configuration report"));
} }
public static class MockLogFactory extends LogFactoryImpl { public static class MockLogFactory extends LogFactoryImpl {
......
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