Class RotateStrategyByTime
java.lang.Object
org.apache.log.output.io.rotate.RotateStrategyByTime
- All Implemented Interfaces:
RotateStrategy
rotation stragety based when log writting started.
- Author:
- Bernhard Huber
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longrotation count.private longtime when logging started.private longtime interval when rotation is triggered. -
Constructor Summary
ConstructorsConstructorDescriptionRotate logs by time.RotateStrategyByTime(long timeInterval) Rotate logs by time. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisRotationNeeded(String data, File file) Check if now a log rotation is neccessary.voidreset()reset interval history counters.
-
Field Details
-
m_timeInterval
private long m_timeIntervaltime interval when rotation is triggered. -
m_startingTime
private long m_startingTimetime when logging started. -
m_currentRotation
private long m_currentRotationrotation count.
-
-
Constructor Details
-
RotateStrategyByTime
public RotateStrategyByTime()Rotate logs by time. By default do log rotation every 24 hours -
RotateStrategyByTime
public RotateStrategyByTime(long timeInterval) Rotate logs by time.- Parameters:
timeInterval- rotate before time-interval [ms] has expired
-
-
Method Details
-
reset
public void reset()reset interval history counters.- Specified by:
resetin interfaceRotateStrategy
-
isRotationNeeded
Check if now a log rotation is neccessary. If(current_time - m_startingTime) / m_timeInterval > m_currentRotationrotation is needed.- Specified by:
isRotationNeededin interfaceRotateStrategy- Parameters:
data- the last message written to the log systemfile- not used- Returns:
- boolean return true if log rotation is neccessary, else false
-