Sending logs

Overview

The observability plugin automatically sends logs to LaunchDarkly. You can also use recordLog to manually create and send a log record.

You can view all logs sent to LaunchDarkly under Logs in the LaunchDarkly user interface. To learn more, read Logs.

Details about each SDK’s configuration are available in the SDK-specific sections below:

Client-side SDKs

This feature is available in the observability plugin for the following client-side SDKs:

JavaScript

Use recordLog to manually create and send a log record:

Record log
1LDObserve.recordLog('Example log message', Severity.DEBUG);

To learn more, read recordLog.

React Native

Use recordLog to manually create and send a log record:

Record log
1LDObserve.recordLog('Example log message', Severity.DEBUG, attributes);

The attributes argument is optional. To construct it, use Attributes from the @opentelemetry/api. To learn more, read recordLog.

React Web

To send a log record with the React Web SDK, follow the example for JavaScript.

Vue

To send a log record with the Vue SDK, follow the example for JavaScript.

Server-side SDKs

This feature is available in the observability plugin for the following server-side SDKs:

Node.js (server-side)

Use recordLog to manually create and send a log record.

Here’s how:

Record log
1LDObserve.recordLog(
2 message,
3 level,
4 secureSessionId,
5 requestId,
6 metadata
7});

The recordLog method automatically provides context propagation, so you can leave the secureSessionId and requestId undefined. Alternatively, you have the option to set their values, to assist with the context propagation. You can parse values for secureSessionId and requestId from the incoming request using LDObserve.parseHeaders().

Python

Use record_log to manually create and send a log record. The log is recorded with LaunchDarkly, but is not sent to other log handlers.

Here’s how:

Record log
1observe.record_log("log message", logging.INFO)

The message to record and log level should be specific to this request. You can optionally pass an array of additional Attributes, which may include any attributes from the OpenTelemetry specification. To learn more, read record_log.