Class IfAccumulatedFileCount
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount
-
- All Implemented Interfaces:
PathCondition
@Plugin(name="IfAccumulatedFileCount", category="Core", printObject=true) public final class IfAccumulatedFileCount extends java.lang.Object implements PathCondition
PathCondition that accepts paths after some count threshold is exceeded during the file tree walk.
-
-
Field Summary
Fields Modifier and Type Field Description private int
count
private static Logger
LOGGER
private PathCondition[]
nestedConditions
private int
threshold
-
Constructor Summary
Constructors Modifier Constructor Description private
IfAccumulatedFileCount(int thresholdParam, PathCondition[] nestedConditions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(java.nio.file.Path basePath, java.nio.file.Path relativePath, java.nio.file.attribute.BasicFileAttributes attrs)
Returnstrue
if the specified candidate path should be deleted,false
otherwise.void
beforeFileTreeWalk()
Invoked before a new file tree walk is started.static IfAccumulatedFileCount
createFileCountCondition(int threshold, PathCondition... nestedConditions)
Create an IfAccumulatedFileCount condition.java.util.List<PathCondition>
getNestedConditions()
int
getThresholdCount()
java.lang.String
toString()
-
-
-
Field Detail
-
LOGGER
private static final Logger LOGGER
-
threshold
private final int threshold
-
count
private int count
-
nestedConditions
private final PathCondition[] nestedConditions
-
-
Constructor Detail
-
IfAccumulatedFileCount
private IfAccumulatedFileCount(int thresholdParam, PathCondition[] nestedConditions)
-
-
Method Detail
-
getThresholdCount
public int getThresholdCount()
-
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:PathCondition
Returnstrue
if the specified candidate path should be deleted,false
otherwise.- Specified by:
accept
in 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:PathCondition
Invoked before a new file tree walk is started. Stateful PathConditions can reset their state when this method is called.- Specified by:
beforeFileTreeWalk
in interfacePathCondition
-
createFileCountCondition
@PluginFactory public static IfAccumulatedFileCount createFileCountCondition(@PluginAttribute(value="exceeds",defaultInt=2147483647) int threshold, @PluginElement("PathConditions") PathCondition... nestedConditions)
Create an IfAccumulatedFileCount condition.- Parameters:
threshold
- The threshold count from which files will be deleted.- Returns:
- An IfAccumulatedFileCount condition.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-