-
Notifications
You must be signed in to change notification settings - Fork 4
[RORDEV-1872] Reproduce issue using log4j2 config provided by customer #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
log4j2 Delete action RollingFileAppender PathConditions condition syntax💡 Result:
Summary of Delete action PathCondition syntax for RollingFileAppender (log4j2)
Delete element: placed inside a RolloverStrategy (DefaultRolloverStrategy, DirectWriteRolloverStrategy, etc.). Key attrs: basePath, maxDepth, followLinks, testMode. [1][5]
Basic PathConditions:
Combining conditions:
ScriptCondition: you can supply a ScriptCondition (Groovy, JavaScript, etc.) that returns the list/boolean to select files; when present, PathCondition elements are ignored. Useful for more complex rules (including deleting empty directories). [1][2][3]
Test mode and safety:
Example (XML):
(This deletes archived files matching the glob older than 60 days.) [1][5]References
[1] Apache Log4j 2 Appenders — Delete action docs (examples & param list).
[2] Apache Log4j 2 Rolling-file manual (Delete, ScriptCondition examples).
[3] HowToDoInJava Log4j2 RollingFileAppender — Delete examples.
🌐 Web query:
log4j2 properties format Delete action configuration DefaultRolloverStrategy nested_condition💡 Result:
Yes — you can configure the Delete action (inside DefaultRolloverStrategy) with nested PathConditions in log4j2.properties. Use the action.type = Delete, then express the outer condition(s) and any nested conditions with the nested_condition namespace (indexed where needed). Example:
Simple: delete files matching a glob and older than 30 days
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basePath = ${baseDir}
appender.rolling.strategy.action.maxDepth = 2
appender.rolling.strategy.action.condition.type = IfFileName
appender.rolling.strategy.action.condition.glob = /app-.log.gz
appender.rolling.strategy.action.condition.nested_condition.type = IfLastModified
appender.rolling.strategy.action.condition.nested_condition.age = 30D
Example using an inner IfAny (logical OR) with two inner conditions (IfAccumulatedFileSize OR IfLastModified):
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basePath = ${baseDir}
appender.rolling.strategy.action.maxDepth = 2
appender.rolling.strategy.action.condition.type = IfFileName
appender.rolling.strategy.action.condition.glob = /app-.log.gz
appender.rolling.strategy.action.condition.nested_condition.type = IfAny
appender.rolling.strategy.action.condition.nested_condition.0.type = IfAccumulatedFileSize
appender.rolling.strategy.action.condition.nested_condition.0.exceeds = 100GB
appender.rolling.strategy.action.condition.nested_condition.1.type = IfLastModified
appender.rolling.strategy.action.condition.nested_condition.1.age = 30D
Notes:
Sources:
[1] Apache Log4j2 RollingFile/Delete examples and XML/Properties guidance. [2] Log4j2 manual: nestedConditions documentation. [3] Community examples showing properties-format nested_condition indexing (StackOverflow).
Remove the non-standard
PathConditionsconfiguration at lines 126–127.Lines 126–127 define
appender.rolling.strategy.action.PathConditions.typeand.glob, which are not valid log4j2 properties-format keys for the Delete action. The correct structure usesappender.rolling.strategy.action.condition(lines 129–136), which already defines the file-matching logic. Delete the redundant lines 126–127; the nested condition structure at lines 129–136 is correct and properly chains the glob pattern match with the IfAny composite condition for size and age checks.🤖 Prompt for AI Agents