spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Log4j2Metrics reset by LoggingSystemShutdownListener

Open dpy1123 opened this issue 2 years ago • 0 comments

I find that the root logger's filter added by log4j2Metrics, reseted sometime after application started.

Since my applcation have multiple context, it will trigger ApplicationEnvironmentPreparedEvent multiple times, and with LoggingSystemShutdownListener and ConfigFileApplicationListener's mechanism, the configration instance in logContext will be replace multiple times, which will lose the filter add by log4j2Metrics.

For now I'm adding a SpringApplicationRunListener#start to rebind the log4j2Metrics, but since it's SpringApplicationRunListener it will also be triggered as many as context's amount. Want a good solution from team, thx!

dpy1123 avatar Feb 17 '23 19:02 dpy1123