# Log4j

<!-- llms-txt-link: /llms.txt -->

> OpenTelemetry Java agent instrumentation

This instrumentation adds trace context (trace ID, span ID, and trace flags) to Log4j's ThreadContext, it does not emit any telemetry on its own.

- **Name**: `log4j-context-data-2.17`
- **Scope**: `io.opentelemetry.log4j-context-data-2.17`
- **Target versions**: `org.apache.logging.log4j:log4j-core:[2.17.0,)`
- **Library**: https://logging.apache.org/log4j/2.x/

## Configuration

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `otel.instrumentation.common.logging.span-id-key` | string | span_id | Specifies the key name used to store the span ID in the logging context. |
| `otel.instrumentation.common.logging.trace-flags-key` | string | trace_flags | Specifies the key name used to store the trace flags in the logging context. |
| `otel.instrumentation.common.logging.trace-id-key` | string | trace_id | Specifies the key name used to store the trace ID in the logging context. |
| `otel.instrumentation.common.mdc.resource-attributes` | list |  | Specifies which resource attributes to add to the logging context as a comma-separated list of attribute keys. |
| `otel.instrumentation.log4j-context-data.add-baggage` | boolean | false | Enables adding baggage entries to the Log4j ThreadContext, prefixed with "baggage.". |

## Data

- **JSON**: [/data/javaagent/instrumentations/log4j-context-data-2.17/log4j-context-data-2.17-395bc1cb90f7.json](/data/javaagent/instrumentations/log4j-context-data-2.17/log4j-context-data-2.17-395bc1cb90f7.json)
- **Explore**: [/java-agent/instrumentation/log4j-context-data-2.17](/java-agent/instrumentation/log4j-context-data-2.17)
