# Log4j

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

> OpenTelemetry Java agent instrumentation

This instrumentation bridges Log4j log events to OpenTelemetry logs.

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

## Configuration

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `otel.instrumentation.log4j-appender.experimental-log-attributes` | boolean | false | Enables the capture of experimental log attributes, including thread name and thread ID. |
| `otel.instrumentation.log4j-appender.experimental.capture-arguments` | boolean | false | Enables the capture of the log message arguments. |
| `otel.instrumentation.log4j-appender.experimental.capture-code-attributes` | boolean | false | Enables the capture of code location attributes, including file path, class name, method name, and line number. |
| `otel.instrumentation.log4j-appender.experimental.capture-map-message-attributes` | boolean | false | Enables the capture of attributes from Log4j MapMessage instances. |
| `otel.instrumentation.log4j-appender.experimental.capture-marker-attribute` | boolean | false | Enables the capture of the Log4j marker attribute. |
| `otel.instrumentation.log4j-appender.experimental.capture-mdc-attributes` | list |  | Controls which MDC attributes to capture. Use "*" to capture all MDC attributes or provide a comma-separated list of specific keys. |
| `otel.instrumentation.log4j-appender.experimental.capture-template` | boolean | false | Enables the capture of the log message template (if arguments are provided). |

## Data

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