# Log4j

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

> OpenTelemetry Java agent instrumentation

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

- **Name**: `log4j-mdc-1.2`
- **Scope**: `io.opentelemetry.log4j-mdc-1.2`
- **Target versions**: `log4j:log4j:[1.2,)`
- **Library**: https://logging.apache.org/log4j/1.2/

## 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. |

## Data

- **JSON**: [/data/javaagent/instrumentations/log4j-mdc-1.2/log4j-mdc-1.2-e01d913a710f.json](/data/javaagent/instrumentations/log4j-mdc-1.2/log4j-mdc-1.2-e01d913a710f.json)
- **Explore**: [/java-agent/instrumentation/log4j-mdc-1.2](/java-agent/instrumentation/log4j-mdc-1.2)
