Log4j2Metrics does not work with programatically added LoggerConfig #5901
Labels
bug
A general bug
instrumentation
An issue that is related to instrumenting a component
module: micrometer-core
An issue that is related to our core module
Milestone
Describe the bug
This is a follow-up issue to #5756 .
In that issue, rebinding when log4j2
Configuration
is reloaded was fixed.However, there is also a case when the existing instance of
Configuration
is updated with a newLoggerConfig
programatically, without actually creating a newConfiguration
instance. This does not work due to the comparison of oldValue with newValue here:micrometer/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/logging/Log4j2Metrics.java
Line 99 in 04f6d8c
Currently the logic for rebinding will only reload if a new
Configuration
instance is loaded, so an added logger to the existingConfiguration
will not get aMetricsFilter
added, even ifupdateLoggers()
is called.For an example of when this might be done in real code, setting log levels in the loggers endpoint of Spring Boot Actuator can create a new
LoggerConfiguration
on an existingConfiguration
.I will provide a PR together with a test that shows when it does not work.
The text was updated successfully, but these errors were encountered: