- Automatically include trace, transaction, and error IDs in your application logs.
- Seamlessly connect logs and traces within the Atatus dashboard.
- Navigate from any log entry to its corresponding trace or error and vice versa.
Log Correlation
Log correlation lets you trace individual requests across systems by automatically adding correlation identifiers (trace, transaction, and error IDs) to your logs. With log correlation enabled, the Atatus Java Agent automatically injects these identifiers into the slf4j MDC (or its equivalent) of supported logging frameworks:
These IDs connect your logs with traces and errors, making it easy to jump from a log entry to its related transaction or exception inside the Atatus dashboard.
Note: Log correlation is enabled by default in all versions of the Atatus Java Agent, so no additional configuration is required.
Supported Logging Frameworks
The Atatus Java Agent supports correlation injection for the following logging frameworks:
For frameworks like
java.util.logging (JUL) that do not provide a native MDC, correlation is supported only by enabling log reformatting in the agent.
Correlation in Structured Logs
For structured logging (such as JSON), the Atatus Java Agent automatically injects the correlation IDs into the logger’s MDC (Mapped Diagnostic Context). Since structured log encoders serialize MDC entries as part of the log record by default, thetrace.id, transaction.id, and error.id fields appear in your log output without any additional configuration.
Correlation in Unstructured (Plain Text) Logs
When using unstructured (plain text) log formats with Logback or log4j, you must update your logging pattern layout to include the MDC values so that the injected correlation IDs appear in your log output. Add%X to log all MDC values, or %X{trace.id} to log only the trace ID.
Logback Example
Update yourlogback.xml pattern to include the correlation IDs:
log4j2 Example
Update yourlog4j2.xml pattern layout:
Example Log Output
After applying the pattern changes above, your plain text logs will look like:Error Capturing and Correlation
When an exception is reported to the logger using calls like:- Reports the error to the Atatus dashboard.
- Generates an
error.idand injects it into the logger MDC for the duration of the logger invocation. - Includes the
error.idin the log output (provided the log pattern allows it).