Documentation forAppOptics

Trace context in logs (legacy agent)

The following content pertains to trace context in logs for the legacy AppOptics Nodejs Agent.

AppOptics agents are no long receiving updates. The new SolarWinds Observability libraries can send APM data in AppOptics and are regularly updated with new features and improvements. If you are still relying on the AppOptics agents and your components are supported by the new libraries, consider transitioning to the SolarWinds Observability libraries for your APM needs. For more information about the benefits of migrating to the SolarWinds Observability libraries. Alternatively, you can use SolarWinds Observability as your primary APM solution.

If you have already transitioned to the new SolarWinds Observability Nodejs Library, see the SolarWinds Nodejs Library documentation for trace context in logs information.

SolarWinds Observability libraries are not compatible with AppOptics agents. Do not use a mix of SolarWinds Observability libraries and AppOptics agents to instrument applications that are part of a distributed trace.

Adding trace context to application logs provides the ability to correlate the log messages from a traced transaction, and if sampled, the log messages to the transaction trace detail. The different ways to enable and use this feature in the Node.js agent are described below, and please check the Supported Components page for the full list of supported logging packages and versions.

Automatic Insertion

Automatic insertion adds the Trace ID directly to the log message, whether by inserting it as an attribute in structured JSON output or appending it to unstructured output. There are two configuration options, see Automatic Insertion of Trace ID into Logs for details.

Automatic Log Attribute / Token

This option creates a token that can be used in the logger's format string, giving you more control over when and where to insert the Trace ID. See Automatic Creation of Trace ID Log Attribute for details.

Using the SDK

If your logger is not supported for automatic insertion, or for finer control, you can use the SDK to add Trace ID to application logs. See the reference guide on ao.getFormattedTraceId and ao.insertLogObject for details and examples.