为什么nlog保留的数量多于所请求的存档文件数? [英] Why does nlog keep more than the requested number of archive files?

查看:443
本文介绍了为什么nlog保留的数量多于所请求的存档文件数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的NLog配置:



I have the NLog configuration below:

<target
    name="MyLog"
    xsi:type="File"
    fileName="./Logs/${shortdate:cached=true}.txt"
    layout="${message}"
    archiveFileName="./Logs/Archive/${longdate}-{##}.txt"
    archiveOldFileOnStartup="true"
    archiveNumbering="DateAndSequence"
    maxArchiveFiles="2">
</target>





它在 / Logs 目录中创建一个日志文件,此文件将移至每次运行应用程序时都会显示 ./ Logs / Archive 目录。问题是我只是获得了越来越多的归档文件。任何人都可以告诉我我做错了导致它不遵守最大存档文件设置吗?



我尝试过:



主文件和存档文件的各种文件命名设置。似乎没有任何东西可以满足只保留两个存档文件的请求。



It creates one log file in the /Logs directory and this file is moved to the ./Logs/Archive directory each time the application runs. The problem is that I just get more and more archived files. Can anyone tell me what I am doing wrong to cause it not to honour the maximum-archived-files setting?

What I have tried:

Various file-naming settings for the main file and the archived files. Nothing seems to get it to honour the request to keep only two archived files.

推荐答案

{shortdate:cached = true} .txt
layout =
{shortdate:cached=true}.txt" layout="


{message}
archiveFileName =./ Logs / Archive /
{message}" archiveFileName="./Logs/Archive/


{longdate} - {##}。txt
archiveOldFileOnStartup =true
archiveNumbering =DateAndSequence
maxArchiveFiles =2>
< / target>
{longdate}-{##}.txt" archiveOldFileOnStartup="true" archiveNumbering="DateAndSequence" maxArchiveFiles="2"> </target>





它在 / Logs 目录中创建一个日志文件,该文件被移动到 ./ Logs / Archive 每次应用程序运行时的目录。问题是我只是获得越来越多的归档文件。任何人都可以告诉我我做错了导致它不遵守最大归档文件设置吗?



我尝试过:



主文件和存档的各种文件命名设置似乎没有任何东西可以让它仅仅遵守保留的要求两个存档文件。



It creates one log file in the /Logs directory and this file is moved to the ./Logs/Archive directory each time the application runs. The problem is that I just get more and more archived files. Can anyone tell me what I am doing wrong to cause it not to honour the maximum-archived-files setting?

What I have tried:

Various file-naming settings for the main file and the archived files. Nothing seems to get it to honour the request to keep only two archived files.


这篇关于为什么nlog保留的数量多于所请求的存档文件数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆