Class ContextDataFactory
- java.lang.Object
-
- org.apache.logging.log4j.core.impl.ContextDataFactory
-
public class ContextDataFactory extends Object
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 theStringMap
interface. The class must have a public default constructor, and if possible should also have a public constructor that takes a singleint
argument for the initial capacity.- Since:
- 2.7
- See Also:
LogEvent.getContextData()
,ContextDataInjector
,SortedArrayStringMap
-
-
Constructor Summary
Constructors Constructor Description ContextDataFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringMap
createContextData()
static StringMap
createContextData(int initialCapacity)
static StringMap
createContextData(Map<String,String> context)
static StringMap
createContextData(ReadOnlyStringMap readOnlyStringMap)
static StringMap
emptyFrozenContextData()
An empty pre-frozen IndexedStringMap.
-
-
-
Method Detail
-
createContextData
public static StringMap createContextData()
-
createContextData
public static StringMap createContextData(int initialCapacity)
-
createContextData
public static StringMap createContextData(ReadOnlyStringMap readOnlyStringMap)
-
emptyFrozenContextData
public static StringMap emptyFrozenContextData()
An empty pre-frozen IndexedStringMap. The returned object may be shared.- Returns:
- an empty pre-frozen IndexedStringMap
-
-