Class ContextDataFactory
java.lang.Object
org.apache.logging.log4j.core.impl.ContextDataFactory
Factory for creating the StringMap instances used to initialize LogEvents' context data. When context data is injected into the log event, these StringMap
instances may be either populated with key-value pairs from the context, or completely replaced altogether.
By default returns SortedArrayStringMap
objects. Can be configured by setting system property
"log4j2.ContextData"
to the fully qualified class name of a class implementing the StringMap
interface. The class must have a public default constructor, and if possible should also have a public constructor
that takes a single int
argument for the initial capacity.
- Since:
- 2.7
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final Constructor<?>
In LOG4J2-2649 (https://issues.apache.org/jira/browse/LOG4J2-2649), the reporter said some reason about using graalvm to static compile.private static final StringMap
private static final Constructor<?>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCachedClass
(String className) static StringMap
static StringMap
createContextData
(int initialCapacity) static StringMap
createContextData
(Map<String, String> context) static StringMap
createContextData
(ReadOnlyStringMap readOnlyStringMap) private static Constructor<?>
createDefaultConstructor
(Class<? extends StringMap> cachedClass) private static Constructor<?>
createInitialCapacityConstructor
(Class<? extends StringMap> cachedClass) static StringMap
An empty pre-frozen IndexedStringMap.
-
Field Details
-
CLASS_NAME
-
CACHED_CLASS
-
DEFAULT_CONSTRUCTOR
In LOG4J2-2649 (https://issues.apache.org/jira/browse/LOG4J2-2649), the reporter said some reason about using graalvm to static compile. In graalvm doc (https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md), graalvm is not support MethodHandle now, so the Constructor need not to return MethodHandle. -
INITIAL_CAPACITY_CONSTRUCTOR
-
EMPTY_STRING_MAP
-
-
Constructor Details
-
ContextDataFactory
public ContextDataFactory()
-
-
Method Details
-
createCachedClass
-
createDefaultConstructor
-
createInitialCapacityConstructor
private static Constructor<?> createInitialCapacityConstructor(Class<? extends StringMap> cachedClass) -
createContextData
-
createContextData
-
createContextData
-
createContextData
-
emptyFrozenContextData
An empty pre-frozen IndexedStringMap. The returned object may be shared.- Returns:
- an empty pre-frozen IndexedStringMap
-