Class AwaitCompletionReliabilityStrategy
java.lang.Object
org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy
- All Implemented Interfaces:
LocationAwareReliabilityStrategy,ReliabilityStrategy
public class AwaitCompletionReliabilityStrategy
extends 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
FieldsModifier and TypeFieldDescriptionprivate final AtomicIntegerprivate final LoggerConfigprivate static final intprivate final Conditionprivate final AtomicBooleanprivate final Lock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled after a log event was logged.private booleanvoidCalled before all appenders are stopped.voidbeforeStopConfiguration(Configuration configuration) Called before the configuration is stopped.For internal use by the ReliabilityStrategy; returns the LoggerConfig to use.voidlog(Supplier<LoggerConfig> reconfigured, String loggerName, String fqcn, StackTraceElement location, Marker marker, Level level, Message data, Throwable t) Logs an event.voidlog(Supplier<LoggerConfig> reconfigured, String loggerName, String fqcn, Marker marker, Level level, Message data, Throwable t) Logs an event.voidlog(Supplier<LoggerConfig> reconfigured, LogEvent event) Logs an event.private voidprivate voidWaits for all log events to complete before returning.
-
Field Details
-
MAX_RETRIES
private static final int MAX_RETRIES- See Also:
-
counter
-
shutdown
-
shutdownLock
-
noLogEvents
-
loggerConfig
-
-
Constructor Details
-
AwaitCompletionReliabilityStrategy
-
-
Method Details
-
log
public void log(Supplier<LoggerConfig> reconfigured, String loggerName, String fqcn, Marker marker, Level level, Message data, Throwable t) Description copied from interface:ReliabilityStrategyLogs an event.- Specified by:
login 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, String loggerName, String fqcn, StackTraceElement location, Marker marker, Level level, Message data, Throwable t) Description copied from interface:LocationAwareReliabilityStrategyLogs an event.- Specified by:
login 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
Description copied from interface:ReliabilityStrategyLogs an event.- Specified by:
login interfaceReliabilityStrategy- Parameters:
reconfigured- supplies the next LoggerConfig if the strategy's LoggerConfig is no longer activeevent- The log event.
-
getActiveLoggerConfig
Description copied from interface:ReliabilityStrategyFor internal use by the ReliabilityStrategy; returns the LoggerConfig to use.- Specified by:
getActiveLoggerConfigin 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:ReliabilityStrategyCalled after a log event was logged.- Specified by:
afterLogEventin interfaceReliabilityStrategy
-
signalCompletionIfShutdown
private void signalCompletionIfShutdown() -
beforeStopAppenders
public void beforeStopAppenders()Description copied from interface:ReliabilityStrategyCalled before all appenders are stopped.- Specified by:
beforeStopAppendersin interfaceReliabilityStrategy
-
waitForCompletion
private void waitForCompletion()Waits for all log events to complete before returning. -
beforeStopConfiguration
Description copied from interface:ReliabilityStrategyCalled before the configuration is stopped.- Specified by:
beforeStopConfigurationin interfaceReliabilityStrategy- Parameters:
configuration- the configuration that will be stopped
-