Skip to content

Consistently coerce false to off and true to on where applicable #17385

@wilkinsona

Description

@wilkinsona

YAML 1.1 maps off to false. We deal with this in LoggingApplicationListener by coercing false back to LogLevel.OFF:

private LogLevel coerceLogLevel(String level) {
String trimmedLevel = level.trim();
if ("false".equalsIgnoreCase(trimmedLevel)) {
return LogLevel.OFF;
}
return LogLevel.valueOf(trimmedLevel.toUpperCase(Locale.ENGLISH));
}

This allows users to configure logging using logging.level.example.my.package: off in YAML.

We do no perform any coercion when turning the banner off so spring.main.banner-mode: off will fail and spring.main.banner-mode: 'off' has to be used instead.

I think we should consistently allow false to be bound to an enum that would accept off. Perhaps this is something that could be done in the binder rather than as a special case for banner mode.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions