登录后如何处理磁盘已满错误? [英] How to handle disk full errors while logging in logback?

查看:46
本文介绍了登录后如何处理磁盘已满错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用slf4j + logback登录我们的应用程序.先前我们使用jcl + log4j并于最近迁移.

I am using slf4j+logback for logging in our application. Earlier we were using jcl+log4j and moved recently.

由于我们应用程序中的大量日志记录,因此生产环境中磁盘可能已满.在这种情况下,我们需要停止日志记录,并且应用程序应该可以正常运行.我从网上发现的是,我们需要轮询 logback StatusManager 以查找此类错误.但是,这将为应用程序添加带有日志回退的依赖关系.对于log4j,我发现我们可以创建一个Appender来停止在这种情况下的日志记录.再次将导致与log4j的应用程序依赖.

Due to the high amount of logging in our application, there is a chance of disk being full in production environment. In such cases we need to stop logging and application should work fine. What I found from the web is that we need to poll logback StatusManager for such errors. But this will add a dependency with logback for the application. For log4j, I found that we can create an Appender which stops logging in such scenarios. That again will cause a application dependency with log4j.

是否可以仅使用slf4j进行配置?或者是否有其他机制可以处理此问题?

Is there a way to configure this with only slf4j or is there any other mechanism to handle this?

推荐答案

您无需执行或配置任何操作.Logback旨在很好地处理这种情况.一旦目标磁盘已满,logback的 FileAppender 将在短时间内停止对其进行写入.一旦延迟过去,它将尝试恢复.如果恢复尝试失败,则等待时间将逐渐增加,最多不超过1小时.如果恢复尝试成功, FileAppender 将再次开始记录.

You do not have to do or configure anything. Logback is designed to handle this situation quite nicely. Once target disk is full, logback's FileAppender will stop writing to it for a certain short amount of time. Once that delay elapses, it will attempt to recover. If the recovery attempt fails, the waiting period is increased gradually up to a maximum of 1 hour. If the recovery attempt succeeds, FileAppender will start logging again.

该过程是完全自动的,并且无缝扩展到 RollingFileAppender .另请参见正常恢复.

The process is entirely automatic and extends seamlessly to RollingFileAppender. See also graceful recovery.

从更贴切的角度来说,优雅的恢复是我最喜欢的注销功能之一.

On a more personal note, graceful recovery is one my favorite logback features.

这篇关于登录后如何处理磁盘已满错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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