Skip to content

Commit 018b49a

Browse files
committed
Expose disruptor discard count in AsyncLoggerContext
1 parent 19f4050 commit 018b49a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java

+10
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,14 @@ public RingBufferAdmin createRingBufferAdmin() {
124124
public void setUseThreadLocals(final boolean useThreadLocals) {
125125
loggerDisruptor.setUseThreadLocals(useThreadLocals);
126126
}
127+
128+
/**
129+
* Returns the number of logging events discarded by the disruptor's queue full policy, or 0 if the disruptor
130+
* does not use a discarding policy or has not discarded.
131+
*
132+
* @return 0 if the disruptor is not configured to discard or has not discarded, otherwise a positive long
133+
*/
134+
public long getDiscardCount() {
135+
return DiscardingAsyncQueueFullPolicy.getDiscardCount(loggerDisruptor.getAsyncQueueFullPolicy());
136+
}
127137
}

log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ WaitStrategy getWaitStrategy() {
6969
return waitStrategy;
7070
}
7171

72+
AsyncQueueFullPolicy getAsyncQueueFullPolicy() {
73+
return asyncQueueFullPolicy;
74+
}
75+
7276
public String getContextName() {
7377
return contextName;
7478
}

log4j-core/src/main/java/org/apache/logging/log4j/core/async/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Provides Asynchronous Logger classes and interfaces for low-latency logging.
1919
*/
2020
@Export
21-
@Version("2.21.0")
21+
@Version("2.22.0")
2222
package org.apache.logging.log4j.core.async;
2323

2424
import org.osgi.annotation.bundle.Export;

0 commit comments

Comments
 (0)