org.apache.log.output.io.rotate
Class RevolvingFileStrategy
java.lang.Object
org.apache.log.output.io.rotate.RevolvingFileStrategy
- FileStrategy
public class RevolvingFileStrategy
extends java.lang.Object
strategy for naming log files based on appending revolving suffix.
If the initial rotation is not specified then the class will attempt to
calculate the rotation number via the following algorithm.
It will search for the file with the highest number in the rotation. It will
then increment its rotation number and use that number. If all files in rotation
are present then it will then set the initial rotation to the next rotation after
the most recently created file.
RevolvingFileStrategy(File baseFile, int maxRotations) - Creation of a new instane ofthe revolving file strategy.
|
RevolvingFileStrategy(File baseFile, int initialRotation, int maxRotations) - Creation of a new instane ofthe revolving file strategy.
|
private int | calculateInitialRotation() - Method that searches through files that
match the pattern for resolving file and determine
the last generation written to.
|
private int | calculateRotationForFile(File file) - Return the rotation for the specified file
|
private int[] | calculateRotations(File[] matchingFiles) - Generate an array of rotation numbers for all the files specified.
|
int | getCurrentRotation() - Retrieve the current rotation number.
|
private File[] | getMatchingFiles() - Get a list of files that could have been part of the rotation.
|
File | nextFile() - Calculate the real file name from the base filename.
|
PATTERN
private static final String PATTERN
m_baseFile
private File m_baseFile
m_decimalFormat
private DecimalFormat m_decimalFormat
m_maxRotations
private int m_maxRotations
m_rotation
private int m_rotation
RevolvingFileStrategy
public RevolvingFileStrategy(File baseFile,
int maxRotations)
Creation of a new instane ofthe revolving file strategy.
baseFile
- the base filemaxRotations
- the maximum number of rotations ??
RevolvingFileStrategy
public RevolvingFileStrategy(File baseFile,
int initialRotation,
int maxRotations)
Creation of a new instane ofthe revolving file strategy.
baseFile
- the base fileinitialRotation
- the number of initial rotations ??maxRotations
- the maximum number of rotations??
calculateInitialRotation
private int calculateInitialRotation()
Method that searches through files that
match the pattern for resolving file and determine
the last generation written to.
calculateRotationForFile
private int calculateRotationForFile(File file)
Return the rotation for the specified file
calculateRotations
private int[] calculateRotations(File[] matchingFiles)
Generate an array of rotation numbers for all the files specified.
matchingFiles
- the files to generate rotation numbers for
- the array containing rotations
getCurrentRotation
public int getCurrentRotation()
Retrieve the current rotation number.
- the current rotation number.
getMatchingFiles
private File[] getMatchingFiles()
Get a list of files that could have been part of the rotation.
- the list of files that match
nextFile
public File nextFile()
Calculate the real file name from the base filename.
- nextFile in interface FileStrategy
- File the calculated file name