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 7d3612fcee..30f00a6488 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 @@ -266,13 +266,20 @@ public class LoggingApplicationListener implements GenericApplicationListener { name = null; } level = environment.resolvePlaceholders(level); - system.setLogLevel(name, LogLevel.valueOf(level.toUpperCase())); + system.setLogLevel(name, coerceLogLevel(level)); } catch (RuntimeException ex) { this.logger.error("Cannot set level: " + level + " for '" + name + "'"); } } + private LogLevel coerceLogLevel(String level) { + if ("false".equalsIgnoreCase(level)) { + return LogLevel.OFF; + } + return LogLevel.valueOf(level.toUpperCase()); + } + public void setOrder(int order) { this.order = order; } 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 7f6c9c4cdc..005188f2fe 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 @@ -287,6 +287,18 @@ public class LoggingApplicationListenerTests { assertThat(this.outputCapture.toString(), not(containsString("testatfatal"))); } + @Test + public void parseLevelsMapsFalseToOff() throws Exception { + EnvironmentTestUtils.addEnvironment(this.context, + "logging.level.org.springframework.boot=false"); + this.initializer.initialize(this.context.getEnvironment(), + this.context.getClassLoader()); + this.logger.debug("testatdebug"); + this.logger.fatal("testatfatal"); + assertThat(this.outputCapture.toString(), not(containsString("testatdebug"))); + assertThat(this.outputCapture.toString(), not(containsString("testatfatal"))); + } + @Test public void parseArgsDisabled() throws Exception { this.initializer.setParseArgs(false);