Class IfAccumulatedFileSize
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize
-
- All Implemented Interfaces:
PathCondition
@Plugin(name="IfAccumulatedFileSize", category="Core", printObject=true) public final class IfAccumulatedFileSize extends java.lang.Object implements PathCondition
PathCondition that accepts paths after the accumulated file size threshold is exceeded during the file tree walk.
-
-
Field Summary
Fields Modifier and Type Field Description private longaccumulatedSizeprivate static LoggerLOGGERprivate PathCondition[]nestedConditionsprivate longthresholdBytes-
Fields inherited from interface org.apache.logging.log4j.core.appender.rolling.action.PathCondition
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Modifier Constructor Description privateIfAccumulatedFileSize(long thresholdSize, PathCondition... nestedConditions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(java.nio.file.Path basePath, java.nio.file.Path relativePath, java.nio.file.attribute.BasicFileAttributes attrs)Returnstrueif the specified candidate path should be deleted,falseotherwise.voidbeforeFileTreeWalk()Invoked before a new file tree walk is started.static IfAccumulatedFileSizecreateFileSizeCondition(java.lang.String size, PathCondition... nestedConditions)Create an IfAccumulatedFileSize condition.java.util.List<PathCondition>getNestedConditions()longgetThresholdBytes()java.lang.StringtoString()
-
-
-
Field Detail
-
LOGGER
private static final Logger LOGGER
-
thresholdBytes
private final long thresholdBytes
-
accumulatedSize
private long accumulatedSize
-
nestedConditions
private final PathCondition[] nestedConditions
-
-
Constructor Detail
-
IfAccumulatedFileSize
private IfAccumulatedFileSize(long thresholdSize, PathCondition... nestedConditions)
-
-
Method Detail
-
getThresholdBytes
public long getThresholdBytes()
-
getNestedConditions
public java.util.List<PathCondition> getNestedConditions()
-
accept
public boolean accept(java.nio.file.Path basePath, java.nio.file.Path relativePath, java.nio.file.attribute.BasicFileAttributes attrs)Description copied from interface:PathConditionReturnstrueif the specified candidate path should be deleted,falseotherwise.- Specified by:
acceptin interfacePathCondition- Parameters:
basePath- the directory from where to start scanning for deletion candidate filesrelativePath- the candidate for deletion. This path is relative to the baseDir.attrs- attributes of the candidate path- Returns:
- whether the candidate path should be deleted
-
beforeFileTreeWalk
public void beforeFileTreeWalk()
Description copied from interface:PathConditionInvoked before a new file tree walk is started. Stateful PathConditions can reset their state when this method is called.- Specified by:
beforeFileTreeWalkin interfacePathCondition
-
createFileSizeCondition
@PluginFactory public static IfAccumulatedFileSize createFileSizeCondition(@PluginAttribute("exceeds") java.lang.String size, @PluginElement("PathConditions") PathCondition... nestedConditions)
Create an IfAccumulatedFileSize condition.- Parameters:
threshold- The threshold accumulated file size from which files will be deleted.- Returns:
- An IfAccumulatedFileSize condition.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-