Skip to content

Archive files are lost when the sequence number in archive suffix reaches the highest possible number #6055

@WenningQiu

Description

@WenningQiu

NLog version: 6.0.6

Platform: .NET Framework 4.8 on Windows.

Current NLog config

           var fileTarget = new FileTarget
            {
                Name = nameof(RollingFileNLogConsumer),
                FileName = filePath,
                ArchiveAboveSize = maxFileSize,
                ArchiveSuffixFormat = "_{1:yyyyMMdd}_{0:00}",
                MaxArchiveFiles = maxNumFiles,
                Layout = pattern.IsNullOrEmpty() ? DefaultLayout : pattern
            };
  • What is the current result?
    When the sequence number reaches the full digits defined in the archive suffix, it goes to the next number, 100, and keeps using/overwriting 100.
D:\Folder>ls -ltr nlog*
-rw-rw-rw-  1 qiuwen01-pa 0 525072 2025-12-04 16:45 nlogfile_20251204_91
-rw-rw-rw-  1 qiuwen01-pa 0 530904 2025-12-04 16:45 nlogfile_20251204_92
-rw-rw-rw-  1 qiuwen01-pa 0 552754 2025-12-04 16:45 nlogfile_20251204_93
-rw-rw-rw-  1 qiuwen01-pa 0 525072 2025-12-04 16:45 nlogfile_20251204_94
-rw-rw-rw-  1 qiuwen01-pa 0 530907 2025-12-04 16:46 nlogfile_20251204_95
-rw-rw-rw-  1 qiuwen01-pa 0 552766 2025-12-04 16:46 nlogfile_20251204_96
-rw-rw-rw-  1 qiuwen01-pa 0 525073 2025-12-04 16:46 nlogfile_20251204_97
-rw-rw-rw-  1 qiuwen01-pa 0 530904 2025-12-04 16:46 nlogfile_20251204_98
-rw-rw-rw-  1 qiuwen01-pa 0 552750 2025-12-04 16:46 nlogfile_20251204_99
-rw-rw-rw-  1 qiuwen01-pa 0 623002 2025-12-04 16:50 nlogfile_20251204_100
-rw-rw-rw-  1 qiuwen01-pa 0 212267 2025-12-04 16:50 nlogfile
  • What is the expected result?
    I expect the sequence number to keep going: 100, 101, 102, 103 and on and on

  • Did you checked the Internal log?
    No

  • Please post full exception details (message, stacktrace, inner exceptions)
    N/A

  • Are there any workarounds? yes/no
    Not that I am aware of.

  • Is there a version in which it did work?
    N/A

  • Can you help us by writing an unit test?
    N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions