A Global Filter can be called once during the isEnabled check and then again 
when the event is actually logged. But Filters that are attached to Loggers, 
Appender-Refs and Appenders should only be called once.  I am not sure why 
thought would be any different with an Async appender.

Ralph



> On Aug 4, 2020, at 12:55 PM, Dennys Fredericci <den...@fredericci.com.br> 
> wrote:
> 
> Hi All,
> 
> There is a library micrometer(https://micrometer.io/) used to collect 
> metrics, one of these metrics is a log rate, several calls for log.info, 
> log.debug, log.warn, etc.
> 
> Micrometer implements a 
> Filter(org.apache.logging.log4j.core.filter.AbstractFilter) and for each call 
> to the method filter we increment a counter.
> 
> After some research, I noticed that the method filter can be called multiple 
> times especially when an Async appender is configured and in this case, we 
> have a wrong logging rate. An application called on time the method 
> log.info("Test..") but the rate can easily be 2 instead of 1.
> 
> I tried to implement a solution but still not correct.
> 
> Now I am wondering if Filter still feasible for this use case, I am quite 
> convinced that will be not possible to use Filter to solve this.
> 
> So, now my question is:  Is there another way to get the number calls for 
> each logging level? Or is there a workaround that can be implemented on the 
> Filter implementation to do the correct count?
> 
> Regards,
> Dennys Fredericci
> 
> 
> 


Reply via email to