简体   繁体   English

NLog不会扩展文件大小

[英]NLog doesn't roll over on file size

I have the following defined for testing to see if the specified log files roll over but I never see it happening. 我为测试定义了以下内容,以查看指定的日志文件是否翻转,但我从未看到过发生。 Any ideas? 有任何想法吗?

<target name="file" xsi:type="File" layout="${message}" 
        filename="${specialfolder:folder=CommonApplicationData}/logs/configlog.log" 
        archiveFileName="configlog.{##}.log" archiveAboveSize="5" archiveNumbering="Rolling" concurrentWrites="True" maxArchiveFiles="50" 
        keepFileOpen="True" encoding="iso-8859-2" enableFileDelete="False"></target>

You should also include the path in your archiveFileName, so something like this will work: 您还应该在archiveFileName中包含该路径,这样可以正常工作:

<target name="file" xsi:type="File" layout="${message}" 
    filename="${specialfolder:folder=CommonApplicationData}/logs/configlog.log"
    archiveFileName="${specialfolder:folder=CommonApplicationData}/logs/archive/configlog.{##}.log" archiveAboveSize="5" archiveNumbering="Rolling" concurrentWrites="True" maxArchiveFiles="50" 
    keepFileOpen="True" encoding="iso-8859-2" enableFileDelete="False"></target>

Also: The archiveAboveSize parameter is in bytes, not megabytes. 另外:archiveAboveSize参数以字节为单位,而不是以兆字节为单位。 At the moment you telling nlog to roll over after 5 bytes, which might be causing issues. 目前,您告诉nlog在5个字节后翻转,这可能会导致问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM