[英]NLog log files not getting compressed but gets deleted
I am trying to zip and archive the old logs. 我正在尝试压缩和存档旧日志。 I used the below target for this purpose. 为此,我使用了以下目标。
<target name="PluginError" xsi:type="File"
layout="${longdate}${message}${exception:format=tostring}"
fileName="${basedir}/logs/Plugin/Error/${date:format=yyyy-MM-dd}.log"
archiveAboveSize="2000000"
archiveNumbering="Rolling"
maxArchiveFiles="10"
archiveFileName="${basedir}/logs/Plugin/Error/log.{#}.txt"
archiveEvery="Day"
enableArchiveFileCompression="true"/>
But this deletes the old log files when count passes 3 instead of zipping them and archiving them. 但这会在count超过3时删除旧的日志文件,而不是将它们压缩并存档。 I am using NLog dll version 4.4.4090.0. 我正在使用NLog dll版本4.4.4090.0。 What am I doing wrong here? 我在这里做错了什么? Any help would be much appreciated. 任何帮助将非常感激。
The configuration you have specified will ensure: 您指定的配置将确保:
If it behaves differently, then please try and change archiveEvery to Minute . 如果行为不同,请尝试将archiveEvery更改为Minute 。 If it continues to only have 3 files in the archive-folder, then please tell. 如果归档文件夹中仍然只有3个文件,请告知。 Else I think some scheduled-task is cleaning up the archives-folder (or you have several NLog-file-targets pointing to the same folder?). 另外,我认为某些计划任务正在清理存档文件夹(或者您有几个指向同一文件夹的NLog文件目标?)。
Maybe also check if you have any files in the Error-folder, that matches the wildcard log*.txt 也许还检查错误文件夹中是否有任何与通配符log * .txt相匹配的文件
i think there you are missing 我想你在那里失踪了
enableArchiveFileCompression="true"
you can use this nlog configuration its working fine http://nlog-project.org/2015/06/09/nlog-4-has-been-released.html 您可以使用此nlog配置正常运行http://nlog-project.org/2015/06/09/nlog-4-has-been-released.html
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
<targets >
<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${message}"
fileName="${basedir}/logs/logfile.txt"
archiveFileName="${basedir}/archives/log.{#}.txt"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="7"
enableArchiveFileCompression="true" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile">
</logger>
</rules>
</nlog>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.