APM agent breaks log.error when using StructuredLogEncoder with ecs format
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- java, spring-boot
调研方向
首先,使用为 ecs 配置的 logback-spring.xml 中的 StructuredLogEncoder,以及对 Logger#error(String, Throwable) 的调用来复现该问题。检查报告中描述的 APM agent、StructuredLogEncoder 和 error 字段之间的交互。完成的标准是日志记录能够生成格式良好的 JSON,且不会出现 appender 异常。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
We are using the version 1.55.5 with experimental Spring Boot 4 support. Since the update we have problems with log.error in SLF4J. This is the logback-spring.xml configuration:
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="org.springframework.boot.logging.logback.StructuredLogEncoder">
<format>ecs</format>
</encoder>
</appender>
When using the apm agent we are seeing this in the logs instead of the real error log:
07:18:54,651 |-ERROR in ch.qos.logback.core.ConsoleAppender[CONSOLE] - Appender [CONSOLE] failed to append. java.lang.IllegalStateException: The name 'error' has already been written
According to my research, this happens if the JSON log already contains a field with the same name, in this case error. Logback uses the field error for a complex object that contains error.message and error.stack_trace. This is also documented in the Elastic Common Schema.
Steps to reproduce
Use the org.springframework.boot.logging.logback.StructuredLogEncoder with ecs format as described and call org.slf4j.Logger#error(java.lang.String, java.lang.Throwable).
Expected behavior
No exception during logging, but a well-formed JSON log containing the error.
- 主要语言
- Java
- 星标
- 593
- 派生
- 337
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 9
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
elastic/apm-agent-java 的其他 Issue
-
agent-java
难度 2/5 1-2 天 新手友好度 62/100
elastic/apm-agent-java#2844 · 2 条评论 ·
维护者通常 1 天内回复
-
Improve docs and add error log related to illegal activation of transaction可能已有人在做 @AzazelSensei 于 35 天前认领。 未关闭docs good first issue
难度 2/5 1-3 小时 新手友好度 68/100
elastic/apm-agent-java#850 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Custom HttpURLConnection throwing unchecked exception can stall the agent可能已有人在做 @jackshirazi 于 6 天前认领。 未关闭agent-java bug
elastic/apm-agent-java#4590 · 已指派 1 人 ·
维护者通常 1 天内回复
-
agent-java community triage
elastic/apm-agent-java#4573 · 4 条评论 ·
维护者通常 1 天内回复
-
agent-java
难度 4/5 3-5 天 新手友好度 55/100
elastic/apm-agent-java#4549 ·
维护者通常 1 天内回复
查看 elastic/apm-agent-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
objectionary/lints#1556 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
wildfly/wildfly-launcher#99 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
apache/rocketmq#11427 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复