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. See Add logs from services.
If trace context is added to logs and those logs are sent to SolarWinds Observability, use the Traces Explorer to see the logs associated with a traced transaction.
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.
If your logger is not supported for automatic insertion, or for finer control, you can use the SDK to add trace context to application logs. See the reference guide on
apm.getTraceStringForLog for details and examples.