You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NLog中maxArchiveDays与DateAndSequence配置的兼容性咨询

Can maxArchiveDays Work with archiveNumbering="DateAndSequence" in NLog?

Great question! Let's break this down clearly since the documentation calls out limitations for pure Sequence mode but doesn't explicitly cover DateAndSequence.

The short answer: Yes, your configuration is fully valid and functional. Here's why:

  • archiveNumbering="DateAndSequence" combines date-based naming with sequence numbers (e.g., app_20240520_001.log, app_20240520_002.log). Unlike pure Sequence mode (which only uses incrementing numbers like app_001.log), this mode embeds a clear date stamp in archive filenames.
  • maxArchiveDays relies on being able to determine the age of archive files. With DateAndSequence, NLog can parse the date from the filename to calculate if a file is older than your specified 30 days. It will automatically clean up any archives where the embedded date is more than 30 days in the past, while keeping all sequence files from the last 30 days intact.

To confirm, here's a simplified working config snippet that mirrors your setup:

<target xsi:type="File"
        name="appLog"
        fileName="./logs/app.log"
        archiveFileName="./logs/app_{#}.log"
        archiveNumbering="DateAndSequence"
        archiveDateFormat="yyyyMMdd"
        maxArchiveDays="30"
        archiveEvery="Day" />

The key distinction from pure Sequence mode is that DateAndSequence provides the date context NLog needs to apply the maxArchiveDays cleanup logic. You won't run into the same limitations here, as the date in the filename gives NLog a concrete reference point for determining file age.

内容的提问来源于stack exchange,提问作者Semperfi89

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 12:27:37