简体   繁体   English

Log4j 2的断路器

[英]Circuit breaker for Log4j 2

Context: Java web application running in Tomcat, Log4j 2 version 2.5. 上下文:在Tomcat中运行的Java Web应用程序,Log4j 2版本2.5。 Logging set up to go to one Sentry instance using the Raven connector and one ELK (ElasticSearch + Logstash + Kibana) instance. 使用Raven连接器和一个ELK(ElasticSearch + Logstash + Kibana)实例将日志设置为转到一个Sentry实例。

Configuration looks like this (anonymized): 配置如下所示(匿名):

<configuration>
  <appenders>
    <Raven name="Sentry">
      <dsn>https://foo@bar.baz/1</dsn>
    </Raven>
    <Socket name="Logstash" host="1.2.3.4" port="1234">
      <SerializedLayout />
    </Socket>
  </appenders>
  <loggers>
    <root level="info">
      <appender-ref ref="Sentry" level="warn" />
      <appender-ref ref="Logstash" />
    </root>
  </loggers>
</configuration>

Problem is that if Sentry or ELK starts acting up (long response times, unreachable, ...), the application threads get blocked trying to log and the application effectively dies. 问题是,如果Sentry或ELK开始起作用(响应时间长,无法访问等),则应用程序线程将在尝试登录时被阻塞,并且应用程序有效地死掉。

Is there a preferred solution to this problem? 有解决此问题的首选方法吗? Some kind of circuit breaker would be ideal here: after detecting a problem with the remote logging destination Log4j 2 would disable the appender for some time. 在这里,某种断路器是理想的:在检测到远程日志记录目标Log4j 2有问题之后,将在一段时间内禁用该附加程序。

We use another appender wrapped in an <Async/> appender , but as far as I understand that is a good solution to make the logging... well, asynchronous, but not to fix the problem of unresponsive log destination. 我们使用包裹在<Async/>附加程序中的另一个附加程序 ,但据我所知,这是使日志记录很好的解决方案,可以异步进行,但不能解决日志目标无响应的问题。

In our system we have a special component called logs-forwarder that collects all the logs by log4j and other systems and forwards them to logstash / splunk etc. what might have you. 在我们的系统中,我们有一个名为logs-forwarder的特殊组件,它可以通过log4j和其他系统收集所有日志,并将它们转发到logstash / splunk等。 So that's one valid option. 所以这是一个有效的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM