You can associate trace IDs with the business logs of an application. This way, when an error occurs in the application, you can access the business logs associated with trace IDs to find out and troubleshoot the error.

Prerequisites

The Application Real-Time Monitoring Service (ARMS) agent is upgraded to V2.6.1.2 or later. For more information, see Update the ARMS agent for Java applications.

Background information

In ARMS, trace IDs can be associated with the business logs of an application based on the Mapped Diagnostic Context (MDC) mechanism. The Log4j, Log4j 2, and Logback mainstream log frameworks are supported.

Associate trace IDs with business logs

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Application Monitoring > Applications. In the top navigation bar, select a region. On the Applications page, click the name of the application that you want to manage.
  3. In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
  4. On the Custom Configuration tab, turn on Link Business Logs with TraceId in the Business Log Linking Settings section.
    sc_am_log_correlation
    Note
    • If Link Business Logs with TraceId is turned on, trace IDs are automatically generated in the business logs.
  5. Add %X{EagleEye-TraceID} to the pattern property of the business log layout. The following figure shows how to add this configuration for the Logback component.
    Note For information about how to obtain {EagleEye-TraceID} from the business code, see ARMS SDK.
    dg_am__layout_pattern
  6. Restart the application.
    If trace IDs are displayed in the business logs of the application, the business logs are associated with the trace IDs, as shown in the following figure. dg_am_log_traceid