> What version of Java are you using? If it is Java 17

Unfortunately, I need to support Java 8 and 11.

> you can still configure Log4j Core to use your own implementation of 
> `AsyncQueueFullPolicy` by setting the `log4j2.asyncQueueFullPolicy` system 
> property

I would do this if I had control of the end user's logging setup. 
Unfortunately, I vend an internal library that is used by a lot of different 
teams. By the time my code is invoked, AsyncLoggerDisruptor has already read 
the system property and initialized the queue full policy. For other log4j 
telemetry I just programmatically inspect the LoggerContext when my code 
initializes, and install a property change listener to listen for configuration 
changes. Even if I vend my own custom AsyncQueueFullPolicy, practically 
speaking I will never get very good coverage, because I would have to go 
convince thousands of developers to change their system properties.

-Adam

On 4/9/24, 4:02 PM, "Piotr P. Karwasz" <piotr.karw...@gmail.com 
<mailto:piotr.karw...@gmail.com>> wrote:

Hi Adam,


On Wed, 10 Apr 2024 at 00:11, Thomas, Adam <adamt...@amazon.com.inva 
<mailto:adamt...@amazon.com.inva>lid> wrote:
> I created a pull request[1] late last year for this, and was encouraged to 
> start a discussion on the dev list at the time.


Be reassured that we didn't forget about your PR, we just have a lot
of changes going on to publish Log4j Core 3.x.


> We run log4j2 on a lot of hosts that are operated by different teams. By 
> default, our users use async logging and use the Discard 
> asyncQueueFullPolicy. As far as I can tell, the status logger gets one WARN 
> message the first time an event is discarded, and during shutdown a TRACE 
> message is emitted if any discards happened. This leaves us with essentially 
> no insight as to whether or not events are actually being discarded, when 
> they are being discarded, or how many we are discarding.


What version of Java are you using? If it is Java 17 or later, you
could use Log4j Core 3.x that is based on a small dependency injection
implementation. While this technical detail is of no importance to
most users, in your case you could use an `InstancePostProcessor`[1]
to intercept the creation of each service class (AsyncQueueFullPolicy
in your case) and instrument it.


If you are running Java 8 or Java 11, you can still configure Log4j
Core to use your own implementation of `AsyncQueueFullPolicy` by
setting the `log4j2.asyncQueueFullPolicy` system property.


Piotr


[1] 
https://github.com/apache/logging-log4j2/blob/main/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/di/spi/InstancePostProcessor.java
 
<https://github.com/apache/logging-log4j2/blob/main/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/di/spi/InstancePostProcessor.java>



Reply via email to