存档的文件大小超出指定的大小,带有NLog的archiveAboveSize

问题描述 投票:0回答:1

我在下面设置了NLog:

<target name="asyncFile" xsi:type="AsyncWrapper" queueLimit="10000" overflowAction="Block">
     <target xsi:type="File"
               fileName="/storage/sdcard0/com.my.app/Logs/${shortdate}.log"
               archiveFileName="/storage/sdcard0/com.my.app/Logs/archived.{#}.log"
               maxArchiveFiles="5"
               archiveDateFormat="yyyy-MM-dd"
               archiveAboveSize="1048576"
               archiveEvery="Day"
               archiveNumbering="DateAndSequence"
               concurrentWrites="true"
               keepFileOpen="false">
       <layout xsi:type="JsonLayout" includeAllProperties="true" excludeProperties="Comma-separated list (string)">
         <attribute name="time" layout="${longdate}" />
         <attribute name="level" layout="${level:upperCase=true}"/>
         <attribute name="message" layout="${message}" />
         <attribute name="exception" layout="${exception}" />
         <attribute name="threadid" layout="${threadid}" />
       </layout>
     </target>
   </target>

预期的行为:生成的存档文件不超过5个,每个文件的最大大小为1MB。

archived.1.log
archived.2.log
archived.3.log
archived.4.log
archived.5.log

实际行为:一个存档文件有40 MB以上的空间

任何想法?

nlog
1个回答
1
投票

不支持将文件名中的${shortdate}archiveFileName一起使用。

© www.soinside.com 2019 - 2024. All rights reserved.