Class ScriptCondition
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.ScriptCondition
-
@Plugin(name="ScriptCondition", category="Core", printObject=true) public class ScriptCondition extends Object
A condition of theDeleteAction
where a user-provided script selects the files to delete from a provided list. The specified script may be aScript
, aScriptFile
or aScriptRef
.
-
-
Constructor Summary
Constructors Constructor Description ScriptCondition(AbstractScript script, Configuration configuration)
Constructs a new ScriptCondition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ScriptCondition
createCondition(AbstractScript script, Configuration configuration)
Creates the ScriptCondition.List<PathWithAttributes>
selectFilesToDelete(Path basePath, List<PathWithAttributes> candidates)
Executes the script
-
-
-
Constructor Detail
-
ScriptCondition
public ScriptCondition(AbstractScript script, Configuration configuration)
Constructs a new ScriptCondition.- Parameters:
script
- the script that can select files to deleteconfiguration
- configuration containing the StrSubstitutor passed to the script
-
-
Method Detail
-
selectFilesToDelete
public List<PathWithAttributes> selectFilesToDelete(Path basePath, List<PathWithAttributes> candidates)
Executes the script- Parameters:
baseDir
-candidates
-- Returns:
-
createCondition
@PluginFactory public static ScriptCondition createCondition(@PluginElement("Script") AbstractScript script, @PluginConfiguration Configuration configuration)
Creates the ScriptCondition.- Parameters:
script
- The script to run. This may be aScript
, aScriptFile
or aScriptRef
. The script must return aList<PathWithAttributes>
. When the script is executed, it is provided the following bindings:- basePath - the directory from where the
Delete
action started scanning for files to delete. Can be used to relativize the paths in the pathList. - pathList - a
java.util.List
containingPathWithAttribute
objects. (The script is free to modify and return this list.) - substitutor - a
StrSubstitutor
that can be used to look up variables embedded in the base dir or other properties - statusLogger - the
StatusLogger
that can be used to log events during script execution - any properties declared in the configuration
- basePath - the directory from where the
configuration
- the configuration- Returns:
- A ScriptCondition.
-
-