Skip to content

Bug Report: Log4j2 2.35.0 + Spring Boot 4.0.3 fails to start with opentelemetry-log4j-context-data-2.17-autoconfigure #16434

@jianhao2010303

Description

@jianhao2010303

Describe the bug

Bug Report: Log4j2 2.35.0 + Spring Boot 4.0.3 fails to start with opentelemetry-log4j-context-data-2.17-autoconfigure

Describe the bug

When using Spring Boot 4.0.3 (which includes Log4j2 2.35.0 by default) together with OpenTelemetry instrumentation:

  • opentelemetry-spring-boot-starter:2.23.0

  • opentelemetry-log4j-context-data-2.17-autoconfigure:2.23.0

The application cannot start and throws:

 

Observations:

  • Application starts normally if OpenTelemetry dependencies are removed.

  • Works fine with Logback, only broken with Log4j2 2.35.0.

  • Excluding old Log4j2 transitive dependencies from OTel does not resolve the issue.

Environment

  • Spring Boot: 4.4.0.3

  • Spring Cloud: 2024.0.0

  • Log4j2: 2.35.0 (provided by Spring Boot)

  • OpenTelemetry Instrumentation: 2.23.0

  • Java: 17+

Steps to reproduce

1. Create a Spring Boot 4.4.0.3 project.

2. Use  spring-boot-starter-log4j2 .

3. Add:

  • opentelemetry-spring-boot-starter

  • opentelemetry-log4j-context-data-2.17-autoconfigure

4. Start the application.

Root Cause Analysis

Log4j2 2.35.0 includes breaking changes in:

  •  org.apache.logging.log4j.core.impl.Log4jLogEvent 

  •  ThreadContextDataInjector  initialization

OpenTelemetry Log4j2 integration does not support Log4j2 2.35.0+ yet.

Expectation

Please add official support for Log4j2 2.35.0+ to work with the latest Spring Boot 4.4.

Steps to reproduce

Please add official support for Log4j2 2.35.0+ to work with the latest Spring Boot 4.4.

Expected behavior

Please add official support for Log4j2 2.35.0+ to work with the latest Spring Boot 4.4.

Actual behavior

Please add official support for Log4j2 2.35.0+ to work with the latest Spring Boot 4.4.

Javaagent or library instrumentation version

opentelemetry-log4j-context-data-2.17-autoconfigure:2.23.0

Environment

JDK: 17
OS: windows

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions