Skip to content

Fix size-only backup scan for prefix siblings - #339

Open
dajiaohuang wants to merge 3 commits into
apache:masterfrom
dajiaohuang:fix/338-prefix-sibling-size-backup
Open

dajiaohuang wants to merge 3 commits into
apache:masterfrom
dajiaohuang:fix/338-prefix-sibling-size-backup

Conversation

@dajiaohuang

Copy link
Copy Markdown

Fixes #338.

Summary

  • Only count a size-only backup when the filename portion before its numeric suffix matches the configured base filename.
  • Add a synthetic regression test for a prefix-sharing unrelated sibling.
  • Leave static-name and date-rolling backup handling unchanged.

Verification

  • The regression test failed on the frozen baseline (CurrentSizeRollBackups was 5 instead of 0) and passed with this change.
  • Restored the solution using a task-local NuGet configuration with the public nuget.org source, then ran dotnet test src/log4net.sln --no-restore: 462 log4net.Tests passed, 1 skipped; 52 log4net.Ext.Mail.Tests passed. Restore reported NU1902/NU1903 advisories for System.Security.Cryptography.Pkcs 10.0.0 in log4net.Ext.Mail.Tests; this PR does not change that dependency.

AI/tool disclosure: prepared with OpenAI Codex gpt-6-luna, operated by dajiaohuang. The tests above were executed by the agent; this disclosure does not claim independent human-authored verification.

dajiaohuang and others added 3 commits October 27, 2026 03:06
- size and once rolling no longer count log.txt.errors.3 as backup 3
- the static name guard from apache#334 now covers names without dates
@FreeAndNil

Copy link
Copy Markdown
Contributor

Thanks @dajiaohuang, the bug is real and your fix is right.

We reshaped it a little before merging:

  • one guard instead of two: the static name check from count only the current date's backups when RollingFileAppender starts #334 now also covers a name without dates
  • the test moved to RollingFileAppenderTest, next to the other InitializeRollBackups tests, and calls it directly, so it needs no subclass and no temp folder
  • a positive case: log.txt.5 still counts as backup 5
  • a changelog entry

Here is the commit on top of your branch: 2fbda3d

Could you pull it into your branch and push? It applies without conflicts, and we squash when merging the PR.

git switch fix/338-prefix-sibling-size-backup
git pull https://github.com/apache/logging-log4net.git Feature/338-size-backup-prefix-sibling
git push

@FreeAndNil FreeAndNil added this to the 3.5.1 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RollingFileAppender counts unrelated prefix siblings as size backups

2 participants