Merge pull request #7639 from chaodhib/patch-1

* pr/7639:
  Broaden LoggingApplicationListener ignores
This commit is contained in:
Phillip Webb
2016-12-19 18:44:59 -08:00
2 changed files with 13 additions and 6 deletions

View File

@@ -314,12 +314,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
}
private boolean ignoreLogConfig(String logConfig) {
return !StringUtils.hasLength(logConfig)
|| isDefaultAzureLoggingConfig(logConfig);
}
private boolean isDefaultAzureLoggingConfig(String candidate) {
return candidate.startsWith("-Djava.util.logging.config.file=");
return !StringUtils.hasLength(logConfig) || logConfig.startsWith("-D");
}
private void initializeFinalLoggingLevels(ConfigurableEnvironment environment,

View File

@@ -162,6 +162,18 @@ public class LoggingApplicationListenerTests {
assertThat(new File(tmpDir() + "/spring.log").exists()).isFalse();
}
@Test
public void tomcatNopLoggingConfigDoesNotCauseAFailure() throws Exception {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
"logging.config: -Dnop");
this.initializer.initialize(this.context.getEnvironment(),
this.context.getClassLoader());
this.logger.info("Hello world");
String output = this.outputCapture.toString().trim();
assertThat(output).contains("Hello world").doesNotContain("???");
assertThat(new File(tmpDir() + "/spring.log").exists()).isFalse();
}
@Test
public void overrideConfigBroken() throws Exception {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,