我可以配置NLog在达到一定限制后修剪日志吗? [英] Can I configure NLog to prune logs after they reach a certain limit?

查看:163
本文介绍了我可以配置NLog在达到一定限制后修剪日志吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将NLog配置为在达到特定文件大小后自动修剪/整理日志文件?

Can NLog be configured to automatically prune/trim a log file after it reaches a certain file size?

推荐答案

我认为,最接近的实现是使用archiveAboveSize属性让NLog在达到一定大小时将日志文件存档.通过将此属性与maxArchiveFiles属性结合使用,可以使归档文件的数量保持最少(尽管我认为您将始终需要一个归档文件,否则当当前日志文件被归档并替换为新的日志文件时,现在-存档文件将被删除,您将失去所有登录记录.)

I think the closest you will achieve will be to use the archiveAboveSize attribute to get NLog to archive the log file when it reaches a certain size. By combining this with the maxArchiveFiles attribute, you can keep the number of archived files to a minimum (although I think you will always need one archived file otherwise when the current log file gets archived and replaced with a new one, the now-archived file will be deleted and you will lose all of the logging in it).

文档中有示例.

这篇关于我可以配置NLog在达到一定限制后修剪日志吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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