Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Log4j2Metrics does not work with programatically added LoggerConfig #5901

Closed
pativa opened this issue Feb 6, 2025 · 0 comments · Fixed by #5902
Closed

Log4j2Metrics does not work with programatically added LoggerConfig #5901

pativa opened this issue Feb 6, 2025 · 0 comments · Fixed by #5902
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

Comments

@pativa
Copy link
Contributor

pativa commented Feb 6, 2025

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 new LoggerConfig programatically, without actually creating a new Configuration instance. This does not work due to the comparison of oldValue with newValue here:

if (listener.getNewValue() instanceof Configuration && listener.getOldValue() != listener.getNewValue()) {

Currently the logic for rebinding will only reload if a new Configuration instance is loaded, so an added logger to the existing Configuration will not get a MetricsFilter added, even if updateLoggers() 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 existing Configuration.

I will provide a PR together with a test that shows when it does not work.

@shakuzen shakuzen added bug A general bug module: micrometer-core An issue that is related to our core module instrumentation An issue that is related to instrumenting a component and removed waiting-for-triage labels Feb 12, 2025
@shakuzen shakuzen added this to the 1.15.0-M3 milestone Feb 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants