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
This commit is contained in:
Phillip Webb 2014-01-16 12:57:13 -08:00
parent c41a3fd5db
commit 53f1488f70
2 changed files with 10 additions and 7 deletions

View File

@ -106,7 +106,8 @@ public class AutoConfigurationReportLoggingInitializer implements
public void logAutoConfigurationReport(boolean isCrashReport) {
if (this.report == 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;
}
this.report = AutoConfigurationReport.get(this.applicationContext
@ -114,10 +115,11 @@ public class AutoConfigurationReportLoggingInitializer implements
}
if (this.report.getConditionAndOutcomesBySource().size() > 0) {
if (isCrashReport && this.logger.isInfoEnabled()) {
this.logger.info(getLogMessage(this.report
.getConditionAndOutcomesBySource()));
this.logger.info("\n\nError starting ApplicationContext. "
+ "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
.getConditionAndOutcomesBySource()));
}

View File

@ -115,7 +115,7 @@ public class AutoConfigurationReportLoggingInitializerTests {
}
@Test
public void logsInfoOnError() {
public void logsInfoAndDebugOnError() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
this.initializer.initialize(context);
context.register(ErrorConfig.class);
@ -128,7 +128,7 @@ public class AutoConfigurationReportLoggingInitializerTests {
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)));
}
@ -171,7 +171,8 @@ public class AutoConfigurationReportLoggingInitializerTests {
this.initializer.onApplicationEvent(new SpringApplicationErrorEvent(
new SpringApplication(), null, new String[0], new RuntimeException(
"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 {