Skip to content

Resetting the log level of a Log4j2 Logger wrongly flags its LoggerConfiguration as explicitly configured #24298

@ST-DDT

Description

@ST-DDT

Spring-Boot: v2.3.5.RELEASE
Log4J2: 2.13.3 (spring-managed)

#Display default configuration
$ curl http://$SERVER/actuator/loggers

{"levels":["OFF","FATAL","ERROR","WARN","INFO","DEBUG","TRACE"],"loggers":{
    "ROOT":{"configuredLevel":null,"effectiveLevel":"WARN"},
    "de":{"configuredLevel":null, "effectiveLevel":"WARN"},

#Configure de Log Level
$ curl http://$SERVER/actuator/loggers/de -d '{"configuredLevel":"info"}' -H "Content-Type: application/json"
$ curl http://$SERVER/actuator/loggers

{"levels":["OFF","FATAL","ERROR","WARN","INFO","DEBUG","TRACE"],"loggers":{
    "ROOT":{"configuredLevel":null,"effectiveLevel":"WARN"},
    "de":{"configuredLevel":"INFO","effectiveLevel":"INFO"},

#Reset/inherit de Log Level
$ curl http://$SERVER/actuator/loggers/de -d '{"configuredLevel":null}' -H "Content-Type: application/json"
$ curl http://$SERVER/actuator/loggers

{"levels":["OFF","FATAL","ERROR","WARN","INFO","DEBUG","TRACE"],"loggers":{
    "ROOT":{"configuredLevel":null,"effectiveLevel":"WARN"},
    "de":{"configuredLevel":"WARN", "effectiveLevel":"WARN"},

#Configure ROOT Log Level
$ curl http://$SERVER/actuator/loggers/ROOT -d '{"configuredLevel":"error"}' -H "Content-Type: application/json"
$ curl http://$SERVER/actuator/loggers

{"levels":["OFF","FATAL","ERROR","WARN","INFO","DEBUG","TRACE"],"loggers":{
    "ROOT":{"configuredLevel":null,"effectiveLevel":"ERROR"},
    "de":{"configuredLevel":"ERROR", "effectiveLevel":"ERROR"},

As you can see the last two jsons display de as configured, but the value (even for the configured flag) is inherited from ROOT.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions