在 log4j 中将异步附加程序与 JMS 附加程序结合使用
我想了解有关 AsyncAppender
lyk
的更多详细信息如果附加的附加程序不起作用,我们可以控制重试吗?
如果附加的附加程序遇到错误 N,它如何处理错误
N 如何从异步附加程序中删除附加的附加程序......
I want to know more details about AsyncAppender
lyk
Can we control retries if attached appender is not working?
How does it handle error if attached appender encounters the error
N how can I remove attached appender from async appender....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如您所知,AsyncAppender 只是其他附加程序的包装器。当您创建 AsyncAppender 时,您已将“真实”附加程序附加到它。
AsyncAppender 将缓冲您的日志消息,直到达到您配置的限制,并将这些日志消息一次性发布到附加的附加程序。
从 AsyncAppender 的代码来看,当缓冲区已满时,它只是为每个附加的附加程序调用 doAppend 方法(简单的 for 循环遍历所有附加程序)。由附加的附加程序来处理错误条件和重试。
我建议通过扩展 SkeletonAppender 并在您重写的方法中自行处理所有内容来实现自定义附加程序。
为了回答你的最后一个问题,AsyncAppender有一个removeAppender方法:
As you know the AsyncAppender is just a wrapper for other appenders. When you create an AsyncAppender you have attach your "real" appenders to it.
The AsyncAppender will buffer your log messages until it has reached your configured limit and publish those log message to the attached appenders all at once.
From the code for AsyncAppender, it is looks like when the buffer is full it simply calls the doAppend method for each attached appender (simple for loop through all appenders). It would be up to the attached appenders to handle error conditions and retries.
I suggest implementing a custom appender by extending SkeletonAppender and handling everything yourself in the methods you override.
To answer your last question, AsyncAppender has a removeAppender method: