Class AsyncQueueFullPolicyFactory
- java.lang.Object
-
- org.apache.logging.log4j.core.async.AsyncQueueFullPolicyFactory
-
public class AsyncQueueFullPolicyFactory extends java.lang.ObjectCreatesAsyncQueueFullPolicyinstances based on user-specified system properties. TheAsyncQueueFullPolicycreated 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 createsDefaultAsyncQueueFullPolicyobjects.If this property has value
"Discard", this factory createsDiscardingAsyncQueueFullPolicyobjects. By default, this router discards events of levelINFO,DEBUGandTRACEif 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
AsyncQueueFullPolicyinterface. The class must have a default constructor.- Since:
- 2.6
-
-
Field Summary
Fields Modifier and Type Field Description private static LoggerLOGGER(package private) static java.lang.StringPROPERTY_NAME_ASYNC_EVENT_ROUTER(package private) static java.lang.StringPROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL(package private) static java.lang.StringPROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER(package private) static java.lang.StringPROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER
-
Constructor Summary
Constructors Constructor Description AsyncQueueFullPolicyFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AsyncQueueFullPolicycreate()Creates and returnsAsyncQueueFullPolicyinstances based on user-specified system properties.private static AsyncQueueFullPolicycreateCustomRouter(java.lang.String router)private static AsyncQueueFullPolicycreateDiscardingAsyncQueueFullPolicy()private static booleanisRouterSelected(java.lang.String propertyValue, java.lang.Class<? extends AsyncQueueFullPolicy> policy, java.lang.String shortPropertyValue)
-
-
-
Field Detail
-
PROPERTY_NAME_ASYNC_EVENT_ROUTER
static final java.lang.String PROPERTY_NAME_ASYNC_EVENT_ROUTER
- See Also:
- Constant Field Values
-
PROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER
static final java.lang.String PROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER
- See Also:
- Constant Field Values
-
PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER
static final java.lang.String PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER
- See Also:
- Constant Field Values
-
PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL
static final java.lang.String PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL
- See Also:
- Constant Field Values
-
LOGGER
private static final Logger LOGGER
-
-
Method Detail
-
create
public static AsyncQueueFullPolicy create()
Creates and returnsAsyncQueueFullPolicyinstances 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 returnsDefaultAsyncQueueFullPolicyobjects.If this property has value
"Discard", this method returnsDiscardingAsyncQueueFullPolicyobjects.For any other value, this method interprets the value as the fully qualified name of a class implementing the
AsyncQueueFullPolicyinterface. The class must have a default constructor.- Returns:
- a new AsyncQueueFullPolicy
-
isRouterSelected
private static boolean isRouterSelected(java.lang.String propertyValue, java.lang.Class<? extends AsyncQueueFullPolicy> policy, java.lang.String shortPropertyValue)
-
createCustomRouter
private static AsyncQueueFullPolicy createCustomRouter(java.lang.String router)
-
createDiscardingAsyncQueueFullPolicy
private static AsyncQueueFullPolicy createDiscardingAsyncQueueFullPolicy()
-
-