GeezerVison is showing github.com — count only the current date's backups when RollingFileAppender starts by Snotface · Pull Request #334 · apache/logging-log4net
Conversation
Snotface
commented
Oct 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
RollingFileAppender miscounted backups at start-up: a .yyyyMMdd date was read as a backup index, other dates' backups raised the count, and a date pattern supplying the extension hid the current date's backups. It now counts only the current date's backups.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
On start-up the appender counts the size backups already on disk and
continues from the highest. It read the number after the last "." of any
matching file, which went wrong in three ways:
- a date pattern without separators (.yyyyMMdd) was read as a backup
number: counting up the next backup was named .20261004, counting down
every size roll walked twenty million names
- with staticLogFileName false, a date pattern that supplies the extension
(.yyyy-MM-dd'.log') and preserveLogFileNameExtension, the current date's
backups were skipped as "from a different date period", so the count
restarted at 0 and the next roll deleted the existing backups
- with a static file name, backups already rolled to an earlier date
raised the current date's count
GetBackupIndex now builds the name the current date's backups must have,
as the appender names them, and counts only files of that name plus .N.
With a static file name, a suffix that parses as a date in DatePattern is
a dated file, not a backup.
A date pattern that formats as a short number (.dd, .MM, .HH, .yyyy)
names the dated file log.txt.10 exactly like backup 10, so one overwrites
the other. For such configurations no numbered backups are made: size
rolling is switched off, the existing file is appended to at start-up when
appendToFile is false, and the reason is written as a FATAL line at the
top of each file and as an internal warning. The new IgnoreDateWarnings
property keeps the configured behaviour for those who accept the risk.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
FreeAndNil
added a commit
that referenced
this pull request
Oct 4, 2026
…334
InitializeRollBackups took dated files and other dates' backups for
backups of the current roll point:
* A date without separators (.yyyyMMdd) parsed as a backup index, with a
static or a non-static name, so the count jumped to 20261004.
* With a static name, log.txt.20261003.1 counted as backup 1.
* A date pattern supplying the extension (.yyyy-MM-dd'.log' with
PreserveLogFileNameExtension) hid the current date's backups.
Dates of up to four characters (.dd) still count as indexes, they cannot
be told apart. Tests by @Snotface.
InitializeRollBackups took dated files and other dates' backups for
backups of the current roll point:
* A date without separators (.yyyyMMdd) parsed as a backup index, with a
static or a non-static name, so the count jumped to 20261004.
* With a static name, log.txt.20261003.1 counted as backup 1.
* A date pattern supplying the extension (.yyyy-MM-dd'.log' with
PreserveLogFileNameExtension) hid the current date's backups.
Dates of up to four characters (.dd) still count as indexes, they cannot
be told apart. Tests by @Snotface.
|
Thanks @Snotface, the backup counting bugs you found are real and your InitializeRollBackups tests pin them down well.
The PR is more than we want in RollingFileAppender for a patch release though:
- a new public property
- size rolling switched off
- a FATAL line in the user's log
- false positives:
.yyyy with maxSizeRollBackups 10 can never meet backup 2024
Here is a smaller fix for the same bugs on top of your branch, with your tests and a changelog entry: ba511c5
Its diff shows what changed against your version. Could you merge or cherry-pick it into your branch and push? It applies without conflicts, and we squash when merging the PR.
git switch feature/apache-date-aware-backup-index
git pull https://github.com/apache/logging-log4net.git Feature/334-rollingfileappender-backup-index
git push
The short date collision (.dd) is existing behaviour and deserves its own issue.
One more request: please keep PR descriptions and changelog entries short. A few lines on what is broken and how it is fixed are much easier to review than a long write-up.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@Snotface are you still interested in merging this PR?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@Snotface I will close this PR on 2026-10-19 when we get no feedback from you.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Sorry, i was away on a conference. Will go through your points and see what i can do. I will provide feedback.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks, merged and pushed. Builds clean, tests pass.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Thanks for your contribution.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
FreeAndNil
added a commit
that referenced
this pull request
Oct 26, 2026
- size and once rolling no longer count log.txt.errors.3 as backup 3
- the static name guard from #334 now covers names without dates
FreeAndNil
added a commit
that referenced
this pull request
Nov 5, 2026
* Fix size-only backup scan for #338
* count only the base name's backups without date rolling #338
- size and once rolling no longer count log.txt.errors.3 as backup 3
- the static name guard from #334 now covers names without dates
---------
Co-authored-by: Jan Friedrich <[email protected]>
This was referenced Nov 12, 2026
This was referenced Nov 16, 2026
This was referenced Nov 23, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|