提问人:Akbar Badhusha 提问时间:11/16/2023 最后编辑:ThomasArdalAkbar Badhusha 更新时间:11/17/2023 访问量:34
NLog:存档日志未删除文件夹。只有文件在过期后被删除
NLog: archive log not deleting the folder. Only file got removed after expiry
问:
在我们的项目中,我们配置了用于日志记录的 NLog。对于每一天,我们都会创建单独的文件夹进行记录。我们还配置了自动存档。一切都很完美,在到期时,日志文件被备份,文件被删除。但是文件夹仍然存在。
var target = new FileTarget
{
Name = LogFileName,
FileName = Path.Combine(logDirectoryPath, @"${date:format=yyyyMMdd}", LogFileName + ".log"),
Layout = @"${date}|${level:uppercase=true}|${message} ${exception:format=ToString}",
ArchiveFileName = Path.Combine(logArchievePath, LogFileName + @"_${date:format=HHmmssfff}.zip"),
ArchiveAboveSize = 10* 1024 * 1024,
EnableArchiveFileCompression = true,
ArchiveEvery = FileArchivePeriod.Day,
ArchiveNumbering = ArchiveNumberingMode.DateAndSequence,
MaxArchiveDays = ConfiguredAdminSetting.MaxLogRetentionDay,
EnableFileDelete = true,
};
LogManager.Configuration.Variables["baseDataPath"] = path;
LogManager.Configuration.AddTarget(LogFileName, target);
如何为存档功能启用文件夹删除?
答: 暂无答案
评论
fileName="${date:format=yyyyMMdd}.log"
archiveFileName="..."