java - 如何设置 FailureSummaryLoggingAppenderListener 以便我知道我的异步 appender 何时删除了日志消息
问题描述
我在大量使用 logback/slf4j 进行日志记录的应用程序上工作。我正在研究使用异步附加程序来增加吞吐量。但是,如果我丢失了日志消息,我想得到一些指示。
但是,我无法将其集成到我们的 logback 配置中。
我们的 logback.xml 文件看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="5 seconds" debug="true">
<include file=".../baselogback.xml"/>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="STDOUT" />
<listener class="net.logstash.logback.appender.listener.FailureSummaryLoggingAppenderListener"/>
<discardingThreshold>0</discardingThreshold>
<queueSize>256</queueSize>
<includeCallerData>false</includeCallerData>
<neverBlock>false</neverBlock>
</appender>
<logger name="..." level="DEBUG" additivity="false">
<appender-ref ref="ASYNC"/>
</logger>
<logger name="..." level="DEBUG" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
在添加“侦听器”行之前,我能够测试服务并验证它是否正确记录事务。当我添加该“侦听器”时,它在启动时失败,并显示以下内容:
Logging system failed to initialize using configuration from '.../logback.xml'
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@5:101 - no applicable action for [listener], current ElementPath is [[configuration][appender][listener]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@5:101 - no applicable action for [listener], current ElementPath is [[configuration][appender][listener]]
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
我在这里想念什么?
更新:
我想我在这里缺少的是这只适用于 TCP 附加程序,而不是控制台附加程序。有没有办法让这样的东西适用于控制台附加程序?
解决方案
推荐阅读
- matrix - 使用 Eigen 进行 Cholesky 分解
- r - 如何随机打乱每一行的列数据并在 R 中获取新索引?
- c# - 如何将来自特定代理服务器的调用重定向到 API?
- javascript - Firebase 函数返回“响应不是有效的 JSON 对象”。
- excel - 获取索引位置的单元格地址
- mongodb - 使用 run-rs 运行 mongod 时出现问题。视窗10
- java - Java中类和接口方法的方法可访问性差异
- amazon-web-services - Selenium 网格 Kubernetes 无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败
- react-native - 无法使用 Detox 和 Jest 进行并行测试
- kubernetes - Kafka Producer 导致 org.apache.kafka.common.network.InvalidReceiveException: Invalid receive