Async log4j2 log events are not counted accurately
See original GitHub issueMicrometer provides the Log4j2Metrics
meter binder to add metrics for Log4j2 log events. Unfortunately the implementation is flawed. It is implemented as a filter, but filters can be invoked multiple times and must therefore not have any side effects.
In practice the filter is invoked multiple times by Log4j2 in many circumstances (e.g. in the presence of multiple and/or async loggers). The result is that the counter is increased multiple times for each single log event and the counter values become too high.
Issue Analytics
- State:
- Created 3 years ago
- Comments:22 (13 by maintainers)
Top Results From Across the Web
Log4j2 asynchronous logging is getting stuck when there is ...
I suspect that your application is producing log events faster than the Appenders can handle. The configuration shows two ConsoleAppenders.
Read more >Log4j 2 Lock-free Asynchronous Loggers for Low-Latency ...
Asynchronous Loggers are a new addition in Log4j 2. Their aim is to return from the call to Logger.log to the application as...
Read more >Log4j – Garbage-free Steady State Logging
If your application is multithreaded and logging performance is important, consider using Async Loggers. The ThreadContext map is not garbage- ...
Read more >Configuring Log4j 2 - Apache Logging Services
</Configuration>. Once an event reaches a logger with its additivity set to false the event will not be passed to any of its...
Read more >Log4j User Guide (PDF) - Apache Logging Services
Log4j 2 contains next-generation Asynchronous Loggers based on the ... no logging events should match while specifying ALL would mean all ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As is not possible to use log4j filters to count log events properly I requested a statistics feature for the log4j team.
With some luck, we can have these counters direct from log4j API.
So, let’s became a log4j2 expert 😄
I just started a thread on log4j2 discussion list to see if is possible to use a filter for that use case.