Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

APM agent breaks log.error when using StructuredLogEncoder with ecs format

オープン
#4,470 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
java, spring-boot

調査の方向性

まず、ecs 用に設定された logback-spring.xml の StructuredLogEncoder と、Logger#error(String, Throwable) の呼び出しを使って問題を再現します。レポートで説明されている APM agent、StructuredLogEncoder、error フィールド間の相互作用を調べます。ロギングによって appender の例外なしに整形式の JSON が生成されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

agent-java community

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
平均マージ
15時間 24分
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

elastic/apm-agent-java のほかの issue

elastic/apm-agent-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。