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
Constructors Constructor Description IdlePurgePolicy(long timeToLive, long checkInterval, ConfigurationScheduler scheduler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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
stop(long timeout, TimeUnit timeUnit)
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.String
toString()
void
update(String key, LogEvent event)
-
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 Detail
-
IdlePurgePolicy
public IdlePurgePolicy(long timeToLive, long checkInterval, ConfigurationScheduler scheduler)
-
-
Method Detail
-
initialize
public void initialize(RoutingAppender routingAppender)
Description copied from interface:PurgePolicy
Initializes with routing appender- Specified by:
initialize
in interfacePurgePolicy
-
stop
public boolean stop(long timeout, TimeUnit timeUnit)
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
public void update(String key, LogEvent event)
- Specified by:
update
in interfacePurgePolicy
- Parameters:
key
- routed appender key
-
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.
-
-