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

如何通过NLog配置实现每10分钟滚动日志文件?

NLog配置调整:改为每10分钟滚动日志

要将日志调整为每10分钟滚动一次,需要修改以下3处配置:

  • 将archiveEvery属性值从Hour改为Minute,同时新增archiveInterval="10"指定滚动间隔为10分钟
  • 更新archiveDateFormat为yyyyMMddHHmm,确保归档文件名包含分钟维度的标识
  • 修改fileName中的日期格式为${date:format=yyyyMMddHHmm},让当前日志文件名也按10分钟周期命名

修改后的完整配置代码如下:

<targets name="GFGLogInfo" xsi:type="BufferingWrapper" bufferSize="2000" flushTimeout="5000" slidingTimeout="false">
    <target  xsi:type="File"
            openFileCacheTimeout="10"
            keepFileOpen="true"
            archiveNumbering="Date"
            archiveEvery="Minute"
            archiveInterval="10"
            archiveDateFormat="yyyyMMddHHmm"
            archiveFileName="${basedir}/../GFGLogs/GFGLog/{#}.log"
            fileName="${basedir}/../GFGLogs/GFGLog/${date:format=yyyyMMddHHmm}.log"
            bufferSize="10485760"
            layout="${message}" />
</targets>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 09:32:59