Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unexpected ArchiveFileName when mixing ArchiveSuffixFormat with archiveNumbering/archiveDateFormat #6063

@John0King

Description

@John0King

nlog version

NLog version: 6.0.6

Platform: .NET8

what happened

with settings

"file": {
  "type": "File",
  "fileName": "${basedir}/logs/nlog.log",
  "layout": "${longdate} [${level}] ${logger} ${message} ${exception} | ${aspnet-request-url:includePort=true:includeQueryString=true} ${aspnet-traceidentifier}  ${newline}",
  "archiveAboveSize": 200000000,
  "maxArchiveFiles": 100,
  "archiveNumbering": "DateAndSequence",
  "archiveDateFormat": "yyyyMMdd",
  "archiveEvery": "Day",
  "archiveSuffixFormat": "_{1:yyyyMMdd}_{0}",
  "archiveOldFileOnStartup": true
}

the archived file name will be nlog20151216_0.log

but when remove the old archiveNumbering and archiveDateFormat
eg.

"file": {
  "type": "File",
  "fileName": "${basedir}/logs/nlog.log",
  "layout": "${longdate} [${level}] ${logger} ${message} ${exception} | ${aspnet-request-url:includePort=true:includeQueryString=true} ${aspnet-traceidentifier}  ${newline}",
  "archiveAboveSize": 200000000,
  "maxArchiveFiles": 100,
  //"archiveNumbering": "DateAndSequence",
  //"archiveDateFormat": "yyyyMMdd",
  "archiveEvery": "Day",
  "archiveSuffixFormat": "_{1:yyyyMMdd}_{0}",
  "archiveOldFileOnStartup": true
}

then the the archived file name will be nlog_20151216_0.log

compare

  • nlog20151216_0.log
  • nlog_20151216_0.log

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions