Documentation forSolarWinds Observability SaaS

Node.js trace context in logs

This topic applies to version 14 of the Node.js Library. If you are using an earlier version, see Node.js trace context in logs (legacy).

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 Library are described below, and please check the Supported Components page for the full list of supported logging packages and versions.

Application logs for your service entity are not included in the data sent by APM libraries. Configure your server or application to send application logs to SolarWinds Observability SaaS. See Add logs from services.

If trace context is added to logs and those logs are sent to SolarWinds Observability SaaS, use the Traces Explorer to see the logs associated with a traced transaction.

Automatic insertion

Automatic insertion adds the trace context fields to the log record. See Automatic insertion of Trace ID into logs for details.

The fields added are trace_id, span_id, trace_flags, and resource.service.name. Supported loggers are:

Use the SDK

If your logger is not supported for automatic insertion, or if you want finer control, you can use the OTel API to add trace context to application logs. For details and examples, see @opentelemetry/api | OpenTelemetry SDK.