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
pull/3661/head
shanman190 9 years ago committed by Andy Wilkinson
parent d241171fff
commit cbd37b583f

@ -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 + "'");

Loading…
Cancel
Save