Skip to content

RollingFileAppender counts unrelated prefix siblings as size backups #338

Open

Description

@dajiaohuang

Summary

A non-static size-only RollingFileAppender can treat unrelated filenames that merely share the base-file prefix as numbered backups when initializing its backup count.

Reproduction

With an empty temporary directory except for log.txt.unrelated.5, configure an appender for log.txt with RollingStyle = Size, StaticLogFileName = false, and unlimited backups. The startup scan accepts the sibling by prefix; backup-index parsing then treats its final .5 as an index. CurrentSizeRollBackups becomes 5 even though there are no backups of log.txt, which can make the next size-backup index begin at 6.

A synthetic NUnit regression test reproduced the baseline behavior: expected 0, observed 5. The proposed guard makes that test pass. Static-name and date-rolling paths are not implicated by this case.

Verification and disclosure

The focused regression test failed against the frozen baseline and passed with the proposed guard. The documented dotnet test src/log4net.sln run passed (log4net.Tests: 462 passed, 1 skipped; log4net.Ext.Mail.Tests: 52 passed). Restore emitted existing NU1902/NU1903 advisories for System.Security.Cryptography.Pkcs 10.0.0 in log4net.Ext.Mail.Tests.

The draft issue and proposed test/code were prepared with OpenAI Codex gpt-6-luna, operated by dajiaohuang. This disclosure does not claim independent human-authored verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions