Class OnStartupTriggeringPolicy
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.appender.rolling.AbstractTriggeringPolicy
-
- org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy
-
- All Implemented Interfaces:
TriggeringPolicy
,LifeCycle
,LifeCycle2
@Plugin(name="OnStartupTriggeringPolicy", category="Core", printObject=true) public class OnStartupTriggeringPolicy extends AbstractTriggeringPolicy
Triggers a rollover on every restart, but only if the file size is greater than zero.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
Fields Modifier and Type Field Description private static long
JVM_START_TIME
private long
minSize
-
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
-
-
Constructor Summary
Constructors Modifier Constructor Description private
OnStartupTriggeringPolicy(long minSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OnStartupTriggeringPolicy
createPolicy(long minSize)
void
initialize(RollingFileManager manager)
Provide the RollingFileManager to the policy.private static long
initStartTime()
Returns the result ofManagementFactory.getRuntimeMXBean().getStartTime()
, or the current system time if JMX is not available.boolean
isTriggeringEvent(LogEvent event)
Determine if a rollover should be triggered.java.lang.String
toString()
-
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, stop
-
-
-
-
Method Detail
-
initStartTime
private static long initStartTime()
Returns the result ofManagementFactory.getRuntimeMXBean().getStartTime()
, or the current system time if JMX is not available.
-
initialize
public void initialize(RollingFileManager manager)
Provide the RollingFileManager to the policy.- Parameters:
manager
- The RollingFileManager.
-
isTriggeringEvent
public boolean isTriggeringEvent(LogEvent event)
Determine if a rollover should be triggered.- Parameters:
event
- A reference to the current event.- Returns:
- true if the target file's timestamp is older than the JVM start time.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createPolicy
@PluginFactory public static OnStartupTriggeringPolicy createPolicy(@PluginAttribute(value="minSize",defaultLong=1L) long minSize)
-
-