Top Description Fields Constructors Methods
org.apache.log.output.io.rotate

public Class RotateStrategyBySize

extends Object
implements RotateStrategy
Class Inheritance
All Implemented Interfaces
org.apache.log.output.io.rotate.RotateStrategy
Imports
java.io.File

Rotation strategy based on size written to log file. The strategy will signal that a rotation is needed if the size goes above a set limit. Due to performance reasons the limit is not strictly enforced, however, the strategy has at most an error of the longest single data message written to the logging system. The error will occur immediately after a rotation, when the strategy is reset and the data that triggered the rotation is written. The strategy's internal counter will then be off with data.length() bytes.
Authors
Leo Sutic, Bernhard Huber

Field Summary

Modifier and TypeField and Description
private long
private long

Constructor Summary

AccessConstructor and Description
public
RotateStrategyBySize()

Rotate logs by size.

public
RotateStrategyBySize(final long
rotate before writing maxSize [byte] of messages
maxSize
)

Rotate logs by size.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

boolean return true if log rotation is neccessary, else false
isRotationNeeded
(final String
the message about to be written to the log system
data
,
final File
not used
file
)

Implements org.apache.log.output.io.rotate.RotateStrategy.isRotationNeeded.

Check if now a log rotation is neccessary.
public void
reset()

Implements org.apache.log.output.io.rotate.RotateStrategy.reset.

Reset log size written so far.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_currentSizeback to summary
private long m_currentSize
m_maxSizeback to summary
private long m_maxSize

Constructor Detail

RotateStrategyBySizeback to summary
public RotateStrategyBySize()

Rotate logs by size. By default do log rotation before writing approx. 1MB of messages

RotateStrategyBySizeback to summary
public RotateStrategyBySize(final long maxSize)

Rotate logs by size.

Parameters
maxSize:long

rotate before writing maxSize [byte] of messages

Method Detail

isRotationNeededback to summary
public boolean isRotationNeeded(final String data, final File file)

Implements org.apache.log.output.io.rotate.RotateStrategy.isRotationNeeded.

Check if now a log rotation is neccessary.

Parameters
data:String

the message about to be written to the log system

file:File

not used

Returns:boolean

boolean return true if log rotation is neccessary, else false

resetback to summary
public void reset()

Implements org.apache.log.output.io.rotate.RotateStrategy.reset.

Reset log size written so far.