Class ReusableLogEventFactory
- java.lang.Object
-
- org.apache.logging.log4j.core.impl.ReusableLogEventFactory
-
- All Implemented Interfaces:
LocationAwareLogEventFactory,LogEventFactory
public class ReusableLogEventFactory extends java.lang.Object implements LogEventFactory, LocationAwareLogEventFactory
Garbage-free LogEventFactory that reuses a single mutable log event.- Since:
- 2.6
-
-
Field Summary
Fields Modifier and Type Field Description private static ClockCLOCKprivate ContextDataInjectorinjectorprivate static java.lang.ThreadLocal<MutableLogEvent>mutableLogEventThreadLocalprivate static ThreadNameCachingStrategyTHREAD_NAME_CACHING_STRATEGY
-
Constructor Summary
Constructors Constructor Description ReusableLogEventFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LogEventcreateEvent(java.lang.String loggerName, Marker marker, java.lang.String fqcn, java.lang.StackTraceElement location, Level level, Message message, java.util.List<Property> properties, java.lang.Throwable t)Creates a log event.LogEventcreateEvent(java.lang.String loggerName, Marker marker, java.lang.String fqcn, Level level, Message message, java.util.List<Property> properties, java.lang.Throwable t)Creates a log event.private static MutableLogEventcreateInstance(MutableLogEvent existing)private static MutableLogEventgetOrCreateMutableLogEvent()static voidrelease(LogEvent logEvent)Switches thereservedflag off if the specified event is a MutableLogEvent, otherwise does nothing.
-
-
-
Field Detail
-
THREAD_NAME_CACHING_STRATEGY
private static final ThreadNameCachingStrategy THREAD_NAME_CACHING_STRATEGY
-
CLOCK
private static final Clock CLOCK
-
mutableLogEventThreadLocal
private static final java.lang.ThreadLocal<MutableLogEvent> mutableLogEventThreadLocal
-
injector
private final ContextDataInjector injector
-
-
Method Detail
-
createEvent
public LogEvent createEvent(java.lang.String loggerName, Marker marker, java.lang.String fqcn, Level level, Message message, java.util.List<Property> properties, java.lang.Throwable t)
Creates a log event.- Specified by:
createEventin interfaceLogEventFactory- Parameters:
loggerName- The name of the Logger.marker- An optional Marker.fqcn- The fully qualified class name of the caller.level- The event Level.message- The Message.properties- Properties to be added to the log event.t- An optional Throwable.- Returns:
- The LogEvent.
-
createEvent
public LogEvent createEvent(java.lang.String loggerName, Marker marker, java.lang.String fqcn, java.lang.StackTraceElement location, Level level, Message message, java.util.List<Property> properties, java.lang.Throwable t)
Creates a log event.- Specified by:
createEventin interfaceLocationAwareLogEventFactory- Specified by:
createEventin interfaceLogEventFactory- Parameters:
loggerName- The name of the Logger.marker- An optional Marker.fqcn- The fully qualified class name of the caller.location- The location of the caller.level- The event Level.message- The Message.properties- Properties to be added to the log event.t- An optional Throwable.- Returns:
- The LogEvent.
-
getOrCreateMutableLogEvent
private static MutableLogEvent getOrCreateMutableLogEvent()
-
createInstance
private static MutableLogEvent createInstance(MutableLogEvent existing)
-
release
public static void release(LogEvent logEvent)
Switches thereservedflag off if the specified event is a MutableLogEvent, otherwise does nothing. This flag is used internally to verify that a reusable log event is no longer in use and can be reused.- Parameters:
logEvent- the log event to make available again- Since:
- 2.7
-
-