spring-cloud / spring-cloud/spring-cloud-commons

Log4j2Metrics reset by LoggingSystemShutdownListener

Open
#1,205 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
751
Forks
744
Avg merge
1d 14h
Merged PRs (30d)
9

Description

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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how LoggingSystemShutdownListener and ConfigFileApplicationListener handle repeated ApplicationEnvironmentPreparedEvent events across multiple contexts. Compare that lifecycle with the log4j2Metrics root-logger filter and the reported SpringApplicationRunListener#start workaround. Done means the filter remains bound when configuration instances are replaced, without requiring per-context rebinding.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.