Package org.apache.log.output.io.rotate
Class RevolvingFileStrategy
- java.lang.Object
-
- org.apache.log.output.io.rotate.RevolvingFileStrategy
-
- All Implemented Interfaces:
FileStrategy
public class RevolvingFileStrategy extends java.lang.Object implements FileStrategy
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.- Author:
- Avalon Development Team, Bernhard Huber, Peter Donald, David Gray
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
m_baseFile
private java.text.DecimalFormat
m_decimalFormat
private int
m_maxRotations
private int
m_rotation
private static java.lang.String
PATTERN
-
Constructor Summary
Constructors Constructor Description RevolvingFileStrategy(java.io.File baseFile, int maxRotations)
Creation of a new instane ofthe revolving file strategy.RevolvingFileStrategy(java.io.File baseFile, int initialRotation, int maxRotations)
Creation of a new instane ofthe revolving file strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(java.io.File file)
Return the rotation for the specified fileprivate int[]
calculateRotations(java.io.File[] matchingFiles)
Generate an array of rotation numbers for all the files specified.int
getCurrentRotation()
Retrieve the current rotation number.private java.io.File[]
getMatchingFiles()
Get a list of files that could have been part of the rotation.java.io.File
nextFile()
Calculate the real file name from the base filename.
-
-
-
Field Detail
-
PATTERN
private static final java.lang.String PATTERN
- See Also:
- Constant Field Values
-
m_decimalFormat
private java.text.DecimalFormat m_decimalFormat
-
m_rotation
private int m_rotation
-
m_maxRotations
private int m_maxRotations
-
m_baseFile
private java.io.File m_baseFile
-
-
Constructor Detail
-
RevolvingFileStrategy
public RevolvingFileStrategy(java.io.File baseFile, int maxRotations)
Creation of a new instane ofthe revolving file strategy.- Parameters:
baseFile
- the base filemaxRotations
- the maximum number of rotations ??
-
RevolvingFileStrategy
public RevolvingFileStrategy(java.io.File baseFile, int initialRotation, int maxRotations)
Creation of a new instane ofthe revolving file strategy.- Parameters:
baseFile
- the base fileinitialRotation
- the number of initial rotations ??maxRotations
- the maximum number of rotations??
-
-
Method Detail
-
nextFile
public java.io.File nextFile()
Calculate the real file name from the base filename.- Specified by:
nextFile
in interfaceFileStrategy
- Returns:
- File the calculated file name
-
getCurrentRotation
public int getCurrentRotation()
Retrieve the current rotation number.- Returns:
- the current rotation number.
-
calculateInitialRotation
private int calculateInitialRotation()
Method that searches through files that match the pattern for resolving file and determine the last generation written to.- Returns:
- the initial rotation
-
calculateRotations
private int[] calculateRotations(java.io.File[] matchingFiles)
Generate an array of rotation numbers for all the files specified.- Parameters:
matchingFiles
- the files to generate rotation numbers for- Returns:
- the array containing rotations
-
calculateRotationForFile
private int calculateRotationForFile(java.io.File file)
Return the rotation for the specified file- Parameters:
file
- the file to check- Returns:
- the rotation of the file
-
getMatchingFiles
private java.io.File[] getMatchingFiles()
Get a list of files that could have been part of the rotation.- Returns:
- the list of files that match
-
-