apache / apache/logging-log4j2

Add support for OpenTelemetry Logging

Open
#2,033 3 comments 6 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

We should consider adding support for the [OpenTelemetry Logging specification](https://opentelemetry.io/docs/specs/otel/logs/) to Log4j API 3.x.

This would require:

- creating a new `log4j-otel` bridge that implements [`LoggerProvider`](https://javadoc.io/static/io.opentelemetry/opentelemetry-api/1.32.0/io/opentelemetry/api/logs/LoggerProvider.html),
- enhance the Log4j API to help with implementation of `log4j-otel`. I am mostly concerned about the [`LogRecordBuilder#setContext`](https://javadoc.io/static/io.opentelemetry/opentelemetry-api/1.32.0/io/opentelemetry/api/logs/LogRecordBuilder.html#setContext(io.opentelemetry.context.Context)) method, i.e. a way to programmatically inject context data into a logging event like we do with [`LogBuilder#withLocation`](https://logging.apache.org/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/LogBuilder.html#withLocation(java.lang.StackTraceElement)) for the location data. We obviously don't expect users to add context data manually in their code, but some instrumentation can do it the same way we inject location with [Log4j Transformer Maven plugin](https://logging.apache.org/log4j/transform/latest/#log4j-transform-maven-plugin).

What do you think?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.