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

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

问题描述

我正在使用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以查找此类错误。但是这将为应用程序添加一个依赖项和logback。
对于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.

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

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