Class ContextDataInjectorFactory
- java.lang.Object
-
- org.apache.logging.log4j.core.impl.ContextDataInjectorFactory
-
public class ContextDataInjectorFactory extends java.lang.ObjectFactory for ContextDataInjectors. Returns a newContextDataInjectorinstance based on the value of system propertylog4j2.ContextDataInjector. Users may use this system property to specify the fully qualified class name of a class that implements theContextDataInjectorinterface. If no value was specified this factory method returns one of the injectors defined inThreadContextDataInjector.- Since:
- 2.7
- See Also:
ContextDataInjector,ReadOnlyStringMap,ThreadContextDataInjector,LogEvent.getContextData()
-
-
Constructor Summary
Constructors Constructor Description ContextDataInjectorFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static ContextDataInjectorcreateDefaultInjector()static ContextDataInjectorcreateInjector()Returns a newContextDataInjectorinstance based on the value of system propertylog4j2.ContextDataInjector.
-
-
-
Method Detail
-
createInjector
public static ContextDataInjector createInjector()
Returns a newContextDataInjectorinstance based on the value of system propertylog4j2.ContextDataInjector. If no value was specified this factory method returns one of theContextDataInjectorclasses defined inThreadContextDataInjectorwhich is most appropriate for the ThreadContext implementation.Note: It is no longer recommended that users provide a custom implementation of the ContextDataInjector. Instead, provide a
ContextDataProvider.Users may use this system property to specify the fully qualified class name of a class that implements the
ContextDataInjectorinterface.When providing a custom
ContextDataInjector, be aware that this method may be invoked multiple times by the various components in Log4j that need access to context data. This includes the object(s) that populate log events, but also various lookups and filters that look at context data to determine whether an event should be logged.- Returns:
- a ContextDataInjector that populates the
ReadOnlyStringMapof allLogEventobjects - See Also:
LogEvent.getContextData(),ContextDataInjector
-
createDefaultInjector
private static ContextDataInjector createDefaultInjector()
-
-