public class FileSizeBackupStrategy2 extends AbstractBackupStrategy
NO_LIMIT| Constructor and Description |
|---|
FileSizeBackupStrategy2(long maxSize,
int maxBackupIndex)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxBackupIndex()
Get the max index of backup.
|
boolean |
shouldBackup(java.io.File file)
Whether we should backup a specified log file.
|
getBackupFileNamepublic FileSizeBackupStrategy2(long maxSize,
int maxBackupIndex)
maxSize - the max size the file can reachmaxBackupIndex - the max backup index, or BackupStrategy2.NO_LIMIT, see getMaxBackupIndex()public boolean shouldBackup(java.io.File file)
BackupStrategyfile - the log filepublic int getMaxBackupIndex()
BackupStrategy2Generally, the max index should be greater than 1, and recommended to be less than 10.
Imagine the normal log file name is 'log', and max backup index is 'n', as the log grows,
a log record would go from 'log' to 'log.bak.1', then to 'log.bak.2', 'log.bak.3', and finally
to 'log.bak.n', the greater index, the older log.
After that, the log record will no longer exist in the file system.
If you don't want to limit the max index, then return BackupStrategy2.NO_LIMIT.
With returning BackupStrategy2.NO_LIMIT, When you backing up, the oldest log would be saved to
'log.bak.1', and then 'log.bak.2'...'log.bak.n', the greater index, the newer log.
Don't return Integer.MAX_VALUE or any value less than 0, otherwise an exception will
be thrown.