Class AwaitCompletionReliabilityStrategy
- java.lang.Object
-
- org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy
-
- All Implemented Interfaces:
LocationAwareReliabilityStrategy
,ReliabilityStrategy
public class AwaitCompletionReliabilityStrategy extends java.lang.Object implements ReliabilityStrategy, LocationAwareReliabilityStrategy
ReliabilityStrategy that counts the number of threads that have started to log an event but have not completed yet, and waits for these threads to finish before allowing the appenders to be stopped.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicInteger
counter
private LoggerConfig
loggerConfig
private static int
MAX_RETRIES
private java.util.concurrent.locks.Condition
noLogEvents
private java.util.concurrent.atomic.AtomicBoolean
shutdown
private java.util.concurrent.locks.Lock
shutdownLock
-
Constructor Summary
Constructors Constructor Description AwaitCompletionReliabilityStrategy(LoggerConfig loggerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterLogEvent()
Called after a log event was logged.private boolean
beforeLogEvent()
void
beforeStopAppenders()
Called before all appenders are stopped.void
beforeStopConfiguration(Configuration configuration)
Called before the configuration is stopped.LoggerConfig
getActiveLoggerConfig(Supplier<LoggerConfig> next)
For internal use by the ReliabilityStrategy; returns the LoggerConfig to use.void
log(Supplier<LoggerConfig> reconfigured, java.lang.String loggerName, java.lang.String fqcn, java.lang.StackTraceElement location, Marker marker, Level level, Message data, java.lang.Throwable t)
Logs an event.void
log(Supplier<LoggerConfig> reconfigured, java.lang.String loggerName, java.lang.String fqcn, Marker marker, Level level, Message data, java.lang.Throwable t)
Logs an event.void
log(Supplier<LoggerConfig> reconfigured, LogEvent event)
Logs an event.private void
signalCompletionIfShutdown()
private void
waitForCompletion()
Waits for all log events to complete before returning.
-
-
-
Field Detail
-
MAX_RETRIES
private static final int MAX_RETRIES
- See Also:
- Constant Field Values
-
counter
private final java.util.concurrent.atomic.AtomicInteger counter
-
shutdown
private final java.util.concurrent.atomic.AtomicBoolean shutdown
-
shutdownLock
private final java.util.concurrent.locks.Lock shutdownLock
-
noLogEvents
private final java.util.concurrent.locks.Condition noLogEvents
-
loggerConfig
private final LoggerConfig loggerConfig
-
-
Constructor Detail
-
AwaitCompletionReliabilityStrategy
public AwaitCompletionReliabilityStrategy(LoggerConfig loggerConfig)
-
-
Method Detail
-
log
public void log(Supplier<LoggerConfig> reconfigured, java.lang.String loggerName, java.lang.String fqcn, Marker marker, Level level, Message data, java.lang.Throwable t)
Description copied from interface:ReliabilityStrategy
Logs an event.- Specified by:
log
in interfaceReliabilityStrategy
- Parameters:
reconfigured
- supplies the next LoggerConfig if the strategy's LoggerConfig is no longer activeloggerName
- The name of the Logger.fqcn
- The fully qualified class name of the caller.marker
- A Marker or null if none is present.level
- The event Level.data
- The Message.t
- A Throwable or null.
-
log
public void log(Supplier<LoggerConfig> reconfigured, java.lang.String loggerName, java.lang.String fqcn, java.lang.StackTraceElement location, Marker marker, Level level, Message data, java.lang.Throwable t)
Description copied from interface:LocationAwareReliabilityStrategy
Logs an event.- Specified by:
log
in interfaceLocationAwareReliabilityStrategy
- Parameters:
reconfigured
- supplies the next LoggerConfig if the strategy's LoggerConfig is no longer activeloggerName
- The name of the Logger.fqcn
- The fully qualified class name of the caller.location
- The location of the caller or null.marker
- A Marker or null if none is present.level
- The event Level.data
- The Message.t
- A Throwable or null.
-
log
public void log(Supplier<LoggerConfig> reconfigured, LogEvent event)
Description copied from interface:ReliabilityStrategy
Logs an event.- Specified by:
log
in interfaceReliabilityStrategy
- Parameters:
reconfigured
- supplies the next LoggerConfig if the strategy's LoggerConfig is no longer activeevent
- The log event.
-
getActiveLoggerConfig
public LoggerConfig getActiveLoggerConfig(Supplier<LoggerConfig> next)
Description copied from interface:ReliabilityStrategy
For internal use by the ReliabilityStrategy; returns the LoggerConfig to use.- Specified by:
getActiveLoggerConfig
in interfaceReliabilityStrategy
- Parameters:
next
- supplies the next LoggerConfig if the strategy's LoggerConfig is no longer active- Returns:
- the currently active LoggerConfig
-
beforeLogEvent
private boolean beforeLogEvent()
-
afterLogEvent
public void afterLogEvent()
Description copied from interface:ReliabilityStrategy
Called after a log event was logged.- Specified by:
afterLogEvent
in interfaceReliabilityStrategy
-
signalCompletionIfShutdown
private void signalCompletionIfShutdown()
-
beforeStopAppenders
public void beforeStopAppenders()
Description copied from interface:ReliabilityStrategy
Called before all appenders are stopped.- Specified by:
beforeStopAppenders
in interfaceReliabilityStrategy
-
waitForCompletion
private void waitForCompletion()
Waits for all log events to complete before returning.
-
beforeStopConfiguration
public void beforeStopConfiguration(Configuration configuration)
Description copied from interface:ReliabilityStrategy
Called before the configuration is stopped.- Specified by:
beforeStopConfiguration
in interfaceReliabilityStrategy
- Parameters:
configuration
- the configuration that will be stopped
-
-