Log42异步记录器在突然关闭应用程序时会如何表现? [英] How does Log42 async logger behaves on sudden shutdown of application?

查看:82
本文介绍了Log42异步记录器在突然关闭应用程序时会如何表现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于异步日志记录,尚未写入目标附加程序并且应用程序/系统关闭的日志会发生什么情况?我们会丢失这些日志(因为它们已经在内存中了)还是有办法恢复它们?

For asynchronous logging, what happens to the logs that are not yet written to the destination appender and the application/system goes down? Do we loose these logs (since they are in memory) or is there a way to recover them?

我不想丢失任何错误级别的日志记录.所以我的下一个问题是:有没有一种方法可以在日志级别为单个追加程序配置同步和异步日志记录?例如我希望我的文件附加程序在INFO/DEBUG异步的同时同步执行ERROR级别的日志记录吗?

I don't want to loose any ERROR level logging. So my next question is: Is there a way to configure sync and async logging for a single appender at log level? For e.g. I want my file appender to perform ERROR level logging synchronously while INFO/DEBUG asynchronously?

提前谢谢!

推荐答案

如果进程正常终止,则将处理队列中的所有事件.参见

If the process dies gracefully, all events in the queue will be processed. See this code for how AsyncLogger shutdown works in detail.

如果不允许该进程进行清理(例如, kill -9 ),则可能会丢失事件.这就是人生.

If the process is not allowed to do cleanup (kill -9 for example) then you may lose events. Such is life.

如果要同步处理ERROR级别的日志事件,但异步处理其他级别,则可能无法使用AsyncLoggers,但可以使用AsyncAppender.您可以将Logger配置为同时路由到FileAppender和AsyncAppender.AsyncAppender路由到FileAppender.然后使用过滤器使AsyncAppender仅接受INFO及以下版本,而FileAppender接受ERROR及以上版本.

If you want ERROR level log events processed synchronously but other levels asynchronously you may not be able to use AsyncLoggers but you can use AsyncAppender. You can configure the Logger(s) to route to both a FileAppender and an AsyncAppender. The AsyncAppender routes to the FileAppender. Then use Filters to make the AsyncAppender only accept INFO and below, while the FileAppender accepts ERROR and above.

这篇关于Log42异步记录器在突然关闭应用程序时会如何表现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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