diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java index 01ac287e04..3a6fdbe53e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java @@ -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, diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java index 6378cbee5d..92536c1f27 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java @@ -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,