case 4690 - NLog 6.2.2: archive suffix keeps log-ayanova-N.txt names and cleans up old archives; log viewer sorted by date

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 17:31:01 -07:00
parent 4098cd4922
commit 91f59d8554
4 changed files with 15 additions and 7 deletions

View File

@@ -132,10 +132,15 @@ namespace AyaNova
fileTarget.FileName = Path.Combine(ServerBootConfig.AYANOVA_LOG_PATH, "log-ayanova.txt");
fileTarget.Layout = "${longdate}|${uppercase:${level}}|${logger}|${message:exceptionSeparator==>:withException=true}";
//NLog 6: ArchiveFileName must stay set, it keeps log-ayanova.txt as the current file and moves full files to archives
//(without it NLog 6 writes straight into numbered files). The archive number comes from ArchiveSuffixFormat, not {#}:
//"-{0}" keeps the documented log-ayanova-1.txt names and lets MaxArchiveFiles clean up archives from earlier versions
//(the NLog 6 default would be log-ayanova_01.txt and leave the old -0 to -8 files behind forever)
//archive numbers keep increasing (no more Rolling), the un-numbered log-ayanova.txt is always the current one
fileTarget.ArchiveFileName = Path.Combine(ServerBootConfig.AYANOVA_LOG_PATH, "log-ayanova-{#}.txt");
fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;//so expect to see 1 to 10 or 0 to ten as may be
fileTarget.ArchiveAboveSize = 1000000;//1mb maximum file size
fileTarget.MaxArchiveFiles = 9;//max 10 files totalling 10mb, the current log-ayanova.txt and log-ayanova-[0-9].txt
fileTarget.ArchiveSuffixFormat = "-{0}";
fileTarget.ArchiveAboveSize = 1000000;//1mb maximum file size
fileTarget.MaxArchiveFiles = 9;//max 10 files totalling 10mb, the current log-ayanova.txt and the 9 most recent numbered archives
// Step 4. Define rules