Class IdlePurgePolicy
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy
- All Implemented Interfaces:
Runnable
,PurgePolicy
,LifeCycle
,LifeCycle2
@Plugin(name="IdlePurgePolicy",
category="Core",
printObject=true)
@Scheduled
public class IdlePurgePolicy
extends AbstractLifeCycle
implements PurgePolicy, Runnable
Policy is purging appenders that were not in use specified time in minutes
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
-
Constructor Summary
ConstructorDescriptionIdlePurgePolicy
(long timeToLive, long checkInterval, ConfigurationScheduler scheduler) -
Method Summary
Modifier and TypeMethodDescriptionstatic PurgePolicy
createPurgePolicy
(String timeToLive, String checkInterval, String timeUnit, Configuration configuration) Create the PurgePolicyvoid
initialize
(RoutingAppender routingAppender) Initializes with routing appendervoid
purge()
Purging appenders that were not in use specified timevoid
run()
boolean
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.toString()
void
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop
-
Constructor Details
-
IdlePurgePolicy
-
-
Method Details
-
initialize
Description copied from interface:PurgePolicy
Initializes with routing appender- Specified by:
initialize
in interfacePurgePolicy
- Parameters:
routingAppender
- the routed appender for purging
-
stop
Description copied from interface:LifeCycle2
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.- Specified by:
stop
in interfaceLifeCycle2
- Overrides:
stop
in classAbstractLifeCycle
- Parameters:
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argument- Returns:
- true if the receiver was stopped cleanly and normally, false otherwise.
-
purge
public void purge()Purging appenders that were not in use specified time- Specified by:
purge
in interfacePurgePolicy
-
update
- Specified by:
update
in interfacePurgePolicy
- Parameters:
key
- routed appender keyevent
- Provides contextual information about a logged message.
-
run
public void run() -
createPurgePolicy
@PluginFactory public static PurgePolicy createPurgePolicy(@PluginAttribute("timeToLive") String timeToLive, @PluginAttribute("checkInterval") String checkInterval, @PluginAttribute("timeUnit") String timeUnit, @PluginConfiguration Configuration configuration) Create the PurgePolicy- Parameters:
timeToLive
- the number of increments of timeUnit before the Appender should be purged.checkInterval
- when all appenders purged, the number of increments of timeUnit to check if any appenders appearedtimeUnit
- the unit of time the timeToLive and the checkInterval is expressed in.- Returns:
- The Routes container.
-
toString
-