public class AsyncQueueFullPolicyFactory
extends java.lang.Object
AsyncQueueFullPolicy
instances based on user-specified system properties. The AsyncQueueFullPolicy
created by this factory is used in AsyncLogger, AsyncLoggerConfig and AsyncAppender
to control if events are logged in the current thread, the background thread, or discarded.
Property "log4j2.AsyncQueueFullPolicy"
controls the routing behaviour. If this property is not specified or has
value "Default"
, this factory creates DefaultAsyncQueueFullPolicy
objects.
If this property has value "Discard"
, this factory creates DiscardingAsyncQueueFullPolicy
objects.
By default, this router discards events of level INFO
, DEBUG
and TRACE
if the queue is full.
This can be adjusted with property "log4j2.DiscardThreshold"
(name of the level at which to start
discarding).
For any other value, this
factory interprets the value as the fully qualified name of a class implementing the AsyncQueueFullPolicy
interface. The class must have a default constructor.
Modifier and Type | Field and Description |
---|---|
private static Logger |
LOGGER |
(package private) static java.lang.String |
PROPERTY_NAME_ASYNC_EVENT_ROUTER |
(package private) static java.lang.String |
PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL |
(package private) static java.lang.String |
PROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER |
(package private) static java.lang.String |
PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER |
Constructor and Description |
---|
AsyncQueueFullPolicyFactory() |
Modifier and Type | Method and Description |
---|---|
static AsyncQueueFullPolicy |
create()
Creates and returns
AsyncQueueFullPolicy instances based on user-specified system properties. |
private static AsyncQueueFullPolicy |
createCustomRouter(java.lang.String router) |
private static AsyncQueueFullPolicy |
createDiscardingAsyncQueueFullPolicy() |
private static boolean |
isRouterSelected(java.lang.String propertyValue,
java.lang.Class<? extends AsyncQueueFullPolicy> policy,
java.lang.String shortPropertyValue) |
static final java.lang.String PROPERTY_NAME_ASYNC_EVENT_ROUTER
static final java.lang.String PROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER
static final java.lang.String PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER
static final java.lang.String PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL
private static final Logger LOGGER
public static AsyncQueueFullPolicy create()
AsyncQueueFullPolicy
instances based on user-specified system properties.
Property "log4j2.AsyncQueueFullPolicy"
controls the routing behaviour. If this property is not specified or
has value "Default"
, this method returns DefaultAsyncQueueFullPolicy
objects.
If this property has value "Discard"
, this method returns DiscardingAsyncQueueFullPolicy
objects.
For any other value, this method interprets the value as the fully qualified name of a class implementing the
AsyncQueueFullPolicy
interface. The class must have a default constructor.
private static boolean isRouterSelected(java.lang.String propertyValue, java.lang.Class<? extends AsyncQueueFullPolicy> policy, java.lang.String shortPropertyValue)
private static AsyncQueueFullPolicy createCustomRouter(java.lang.String router)
private static AsyncQueueFullPolicy createDiscardingAsyncQueueFullPolicy()