mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
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
This commit is contained in:
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…
Reference in New Issue
Block a user