From cbd37b583ff00f33553e92249b3ece3fa543f675 Mon Sep 17 00:00:00 2001 From: shanman190 Date: Thu, 30 Jul 2015 16:37:35 -0500 Subject: [PATCH] Make it easier to use YAML configuration to turn off a logger A level named off is used to disable logging for a particular logger. YAML interprets off as false, leading to a failed attempt to get the LogLevel for FALSE. A workaround is to quote the level, i.e. use "off" rather than off. This commit updates LoggingApplicationListener to coerce the string false back to the level off. Closes gh-3631 See gh-3628 --- .../boot/logging/LoggingApplicationListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 6c7bfa44646..4d6873b844b 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 @@ -246,7 +246,12 @@ public class LoggingApplicationListener implements SmartApplicationListener { name = null; } level = environment.resolvePlaceholders(level); - system.setLogLevel(name, LogLevel.valueOf(level.toUpperCase())); + if (Boolean.toString(false).equalsIgnoreCase(level)) { + system.setLogLevel(name, LogLevel.OFF); + } + else { + system.setLogLevel(name, LogLevel.valueOf(level.toUpperCase())); + } } catch (RuntimeException ex) { this.logger.error("Cannot set level: " + level + " for '" + name + "'");