@Plugin(name="DirectWriteRolloverStrategy", category="Core", printObject=true) public class DirectWriteRolloverStrategy extends AbstractRolloverStrategy implements DirectFileRolloverStrategy
DirectWriteRolloverStrategy
writes directly to the file as resolved by the file
pattern. Files will be renamed files according to an algorithm as described below.
The DirectWriteRolloverStrategy uses similar logic as DefaultRolloverStrategy to determine the file name based on the file pattern, however the DirectWriteRolloverStrategy writes directly to a file and does not rename it during rollover, except if it is compressed, in which case it will add the appropriate file extension.
Modifier and Type | Class and Description |
---|---|
static class |
DirectWriteRolloverStrategy.Builder
Builds DirectWriteRolloverStrategy instances.
|
LOGGER, PATTERN_COUNTER, strSubstitutor
Modifier | Constructor and Description |
---|---|
protected |
DirectWriteRolloverStrategy(int maxFiles,
int compressionLevel,
StrSubstitutor strSubstitutor,
Action[] customActions,
boolean stopCustomActionsOnError)
Deprecated.
Since 2.9 Added tempCompressedFilePatternString parameter
|
protected |
DirectWriteRolloverStrategy(int maxFiles,
int compressionLevel,
StrSubstitutor strSubstitutor,
Action[] customActions,
boolean stopCustomActionsOnError,
String tempCompressedFilePatternString)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clearCurrentFileName() |
static DirectWriteRolloverStrategy |
createStrategy(String maxFiles,
String compressionLevelStr,
Action[] customActions,
boolean stopCustomActionsOnError,
Configuration config)
Deprecated.
Since 2.9 Usage of Builder API is preferable
|
int |
getCompressionLevel() |
String |
getCurrentFileName(RollingFileManager manager) |
List<Action> |
getCustomActions() |
int |
getMaxFiles() |
PatternProcessor |
getTempCompressedFilePattern() |
boolean |
isStopCustomActionsOnError() |
static DirectWriteRolloverStrategy.Builder |
newBuilder() |
RolloverDescription |
rollover(RollingFileManager manager)
Performs the rollover.
|
String |
toString() |
getEligibleFiles, getEligibleFiles, getEligibleFiles, getEligibleFiles, getEligibleFiles, getStrSubstitutor, merge, suffixLength
@Deprecated protected DirectWriteRolloverStrategy(int maxFiles, int compressionLevel, StrSubstitutor strSubstitutor, Action[] customActions, boolean stopCustomActionsOnError)
maxFiles
- The maximum number of files that match the date portion of the pattern to keep.customActions
- custom actions to perform asynchronously after rolloverstopCustomActionsOnError
- whether to stop executing asynchronous actions if an error occursprotected DirectWriteRolloverStrategy(int maxFiles, int compressionLevel, StrSubstitutor strSubstitutor, Action[] customActions, boolean stopCustomActionsOnError, String tempCompressedFilePatternString)
maxFiles
- The maximum number of files that match the date portion of the pattern to keep.customActions
- custom actions to perform asynchronously after rolloverstopCustomActionsOnError
- whether to stop executing asynchronous actions if an error occurstempCompressedFilePatternString
- File pattern of the working file
used during compression, if null no temporary file are used@PluginBuilderFactory public static DirectWriteRolloverStrategy.Builder newBuilder()
@Deprecated @PluginFactory public static DirectWriteRolloverStrategy createStrategy(@PluginAttribute(value="maxFiles") String maxFiles, @PluginAttribute(value="compressionLevel") String compressionLevelStr, @PluginElement(value="Actions") Action[] customActions, @PluginAttribute(value="stopCustomActionsOnError",defaultBoolean=true) boolean stopCustomActionsOnError, @PluginConfiguration Configuration config)
maxFiles
- The maximum number of files that match the date portion of the pattern to keep.compressionLevelStr
- The compression level, 0 (less) through 9 (more); applies only to ZIP files.customActions
- custom actions to perform asynchronously after rolloverstopCustomActionsOnError
- whether to stop executing asynchronous actions if an error occursconfig
- The Configuration.public int getCompressionLevel()
public List<Action> getCustomActions()
public int getMaxFiles()
public boolean isStopCustomActionsOnError()
public PatternProcessor getTempCompressedFilePattern()
public String getCurrentFileName(RollingFileManager manager)
getCurrentFileName
in interface DirectFileRolloverStrategy
public void clearCurrentFileName()
clearCurrentFileName
in interface DirectFileRolloverStrategy
public RolloverDescription rollover(RollingFileManager manager) throws SecurityException
rollover
in interface RolloverStrategy
manager
- The RollingFileManager name for current active log file.SecurityException
- if an error occurs.Copyright © 1999-2020 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.