Acquire Dependencies
- Agent
- SDK
Install the OpenTelemetry Java agent.
The Log4j appender is bundled with the agent and installs automatically.
Install the Log Appender
- Agent
- SDK
The Log4j appender is bundled with the agent and requires no additional configuration.
Configure Log4j
Configure Log4j using a configuration file.
The following example logs all messages to both the console and the OpenTelemetry log appender.The Then, in your application code you can use Log4j’s
packages property on the top-level Configuration element tells Log4j to scan for custom appenders in the package.
The OpenTelemetry appender is defined in Appenders and referenced in the root logger (Loggers > Root).LogManager to create loggers and emit log messages:Available Log Appenders
OpenTelemetry Java includes log appenders for popular logging frameworks. Each appender intercepts log messages and routes them through the OpenTelemetry export pipeline. Available log appenders include:- Log4j Appender
- Logback
- JBoss Logmanager (agent only)