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 longJVM_START_TIMEprivate longminSize-
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
-
-
Constructor Summary
Constructors Modifier Constructor Description privateOnStartupTriggeringPolicy(long minSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OnStartupTriggeringPolicycreatePolicy(long minSize)voidinitialize(RollingFileManager manager)Provide the RollingFileManager to the policy.private static longinitStartTime()Returns the result ofManagementFactory.getRuntimeMXBean().getStartTime(), or the current system time if JMX is not available.booleanisTriggeringEvent(LogEvent event)Determine if a rollover should be triggered.java.lang.StringtoString()-
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:
toStringin classjava.lang.Object
-
createPolicy
@PluginFactory public static OnStartupTriggeringPolicy createPolicy(@PluginAttribute(value="minSize",defaultLong=1L) long minSize)
-
-