Updated on 2024-03-12 GMT+08:00

Associating Traces with Logs

Application Scope

Common log frameworks, such as Logback and Log4j.

Example

<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS}} | gtraceid: %X{apm-gtraceid} | traceid: %X{apm-traceid} | spanId: %X{apm-spanid}">

</property>

Trace Parameters

  1. apm-traceid: unique ID of a trace collected by APM.
    Figure 1 Unique ID of a trace
  2. apm-gtraceid: unique ID of a trace which is not sampled.

    APM has a certain sampling ratio. The apm-gtrace-id parameter is used to uniquely identify a trace that is not sampled.

  3. apm-spanid: ID of a microservice called in a trace. Example:
    Figure 2 Calls between microservices