Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This topic explains how to configure the logging feature. Logging is available for client-side, server-side, and edge SDKs. LaunchDarkly SDKs rely on built-in logging packages and libraries to track events. Depending on which language you use, you can configure logging behavior to be highly or minimally verbose.Client-side SDKs
This feature is available in the following client-side SDKs:- .NET (client-side)
- Android
- C++ (client-side)
- Electron
- Flutter
- iOS
- JavaScript
- Node.js (client-side)
- React Native
- React Web
- Roku
.NET (client-side)
Expand .NET (client-side) code sample
Expand .NET (client-side) code sample
Common.Logging framework. For an example configuration, read the Common.Logging README.There are two important things to consider before you enable the DEBUG log level:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
Android
Expand Android code sample
Expand Android code sample
C++ (client-side)
Expand C++ (client-side) code sample
Expand C++ (client-side) code sample
LoggingBuilder before the client is initialized. You cannot modify logging while the client is running.If you use the default logger, you can configure how verbose it should be. The options are debug, info, warn, and error.Here is an example:ILogBackend interface. If you are working with the C binding, define the callback functions to implement the log backend interface.Here’s how:Electron
Expand Electron code sample
Expand Electron code sample
winston package. There are four logging levels: debug, info, warn, and error. By default, debug messages are hidden.To change the logging configuration, you can set LDOptions.logger to either another Winston instance or any object that implements the LDLogger interface. The createConsoleLogger function creates a minimal logger.Flutter
Expand Flutter code sample
Expand Flutter code sample
debug, info, warn, and error. You can also set the level to none to disable all logging.By default, the SDK logs at the info level with a tag of “LaunchDarkly.” To change the logging, construct an LDLogger and include it in your LDConfig. You can change the log level, tag, and output destinations when you construct the logger.Here’s how:LDLogAdapter interface.To learn more, read LDLogger.iOS
Expand iOS code sample
Expand iOS code sample
os_log. The SDK provides a default logger OSLog(subsystem: "com.launchdarkly", category: "ios-client-sdk"). This logger can be overridden using the LDConfig.logger property.Here’s how:Java
ScriptExpand JavaScript code sample
Expand JavaScript code sample
debug.To change the logging configuration, set LDOptions.logger to any object that implements the LDLogger interface and performs logging for the client. To learn more, read LDOptions and LDLogger in the SDK API docs.Node.js (client-side)
Expand Node.js (client-side) code sample
Expand Node.js (client-side) code sample
debug.Versions 1.x of the SDK used the winston logging package for the default configuration. Versions 2.0 and later do not have a dependency on winston. Instead, they write directly to the console by default.For full control over logging behavior, you can set the logger option to an object that implements the LDLogger interface. To learn more about the logger’s requirements and methods, read LDLogger. The winston package is compatible with this interface, so if you are already using a winston logger, you can pass it directly to the SDK.You can use basicLogger for simpler control over logging behavior. Versions 2.x and earlier of the SDK do not support basicLogger.This example shows how to use basicLogger to enable debug-level logging in your SDK configuration:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly users you create when you use this SDK.
React Native
Expand React Native code sample
Expand React Native code sample
BasicLogger. This sends output to the console, with a default log level of info.You can use BasicLogger to make some changes to logging behavior. For full control over logging behavior, you can set the LDOptions.logger option to an object that implements the LDLogger interface and performs logging for the client.This example shows how to use BasicLogger to enable debug-level logging in your SDK configuration:LDOptions and LDLogger.React Web
Expand React Web code sample
Expand React Web code sample
debug.To change the logging configuration, set LDOptions.logger to any object that implements the LDLogger interface and performs logging for the client. The basicLogger, available in the JavaScript SDK, produces such an object.Here’s how:Roku
Expand Roku code sample
Expand Roku code sample
Log levels in the Roku SDK
You can configure the SDK log level. For example, to set the level toinfo:Legacy API custom logger for the Roku SDK
Here is an example of the legacy API custom logger:Scene
Graph API custom logger for the Roku SDKHere is an example of the SceneGraph API custom logger:Server-side SDKs
This feature is available in the following server-side SDKs:.NET (server-side)
Expand .NET (server-side) code sample
Expand .NET (server-side) code sample
Debug, Info, Warn, and Error. By default, the lowest enabled level is Info, so Debug messages are hidden. There are two important things to consider if you enable the Debug level:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
Console.Error by default. The ConfigurationBuilder.Logging method and the LaunchDarkly.Logging API allow you to change the output destination and log level.Here is an example:Microsoft.Extensions.Logging API in this example:LaunchDarkly.Logging.All log messages from the SDK are tagged with a logger name, indicating the category of messages. If you use a logging framework like Microsoft.Extensions.Logging or NLog, you can use these names to filter the output:LaunchDarkly.Sdk: general messages about the operation of the SDK client.LaunchDarkly.Sdk.DataSource: messages about how the SDK client receives feature flag data, such as if the connection to LaunchDarkly has been interrupted.LaunchDarkly.Sdk.DataStore(or more specific names likeLaunchDarkly.Sdk.DataStore.Redis): messages about how the SDK client stores feature flag data, such as if you are using a database integration.LaunchDarkly.Sdk.Evaluation: messages about unusual conditions during feature flag evaluation, such as if a feature flag could not be evaluated because its configuration is invalid.LaunchDarkly.Sdk.Events: messages about analytics events, such as if event data could not be sent to LaunchDarkly due to a network problem.
- The mechanism for specifying a log destination was the
Common.Loggingframework. - If you did not specifically configure a log destination using
Common.Logging, logging was disabled by default. - The main logger name was
LaunchDarkly.Client.LdClient.
C++ (server-side)
Expand C++ (server-side) code sample
Expand C++ (server-side) code sample
LoggingBuilder before the client is initialized. You cannot modify logging while the client is running.If you use the default logger, you can configure how verbose it should be. The options are debug, info, warn, and error.Here is an example:ILogBackend interface. If you are working with the C binding, define the callback functions to implement the log backend interface.Here’s how:Go
Expand Go code sample
Expand Go code sample
log.Logger or anything with a compatible interface. This adds a system of log levels similar to logging frameworks on other platforms. There are four logging levels: Debug, Info, Warn, and Error.By default, all levels of messages are enabled except Debug. You can tell the SDK to enable more or fewer levels, to send the output to a different destination, or to disable logging.Here’s how:Debug log level:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
Java
Expand Java code sample
Expand Java code sample
LDConfig.Builder.logging method and the com.launchdarkly.logging API.If you do not specify a destination, the default behavior depends on the version of the SDK:- In versions 5.10.0 and earlier, the default destination is SLF4J. SLF4J has its own configuration mechanisms for determining where output will go, and for filtering by level and/or logger name. It will not generate any output unless you have provided a configuration. For an example of using SLF4J with a simple console logging configuration, visit an SLF4J-specific version of hello-java.
- Starting with version 6.0.0, the SDK does not require SLF4J. Instead, it detects whether the application is already using SLF4J. If the SLF4J classes are present in the classpath, then it sends log output to SLF4J by default. If the SLF4J classes are not present in the classpath, then it sends log output to
System.errby default.
System.out), and enabling DEBUG level:com.launchdarkly.logging.All log messages from the SDK are tagged with a logger name, indicating the category of messages. If you use a logging framework like SLF4J, you can use these names to filter the output:com.launchdarkly.sdk.server.LDClient: This is for general messages that do not fall into any other categories.com.launchdarkly.sdk.server.LDClient.DataSource: This is for messages related to how the SDK obtains feature flag data. Usually, this means messages about the streaming connection to LaunchDarkly, but if you use polling mode or file data instead, the SDK logs those messages under this name.com.launchdarkly.sdk.server.LDClient.DataStore: This is for messages related to how feature flag data is stored. For example, database errors appear here if you are using a database integration.com.launchdarkly.sdk.server.LDClient.Evaluation: This is for messages related to feature flag evaluation.com.launchdarkly.sdk.server.LDClient.Events: This is for messages related to analytics event processing.
com.launchdarkly.client. or com.launchdarkly.eventsource.There are two important things to consider before you enable the DEBUG log level:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
Lua
Expand Lua code sample
Expand Lua code sample
Node.js (server-side)
Expand Node.js (server-side) code sample
Expand Node.js (server-side) code sample
debug.Pre-6.0 versions of the SDK used the winston logging package for the default configuration. Versions 6.0 and later write directly to the console by default.For full control over logging behavior, you can set the logger option to an object that implements the LDLogger interface. To learn more about the logger’s requirements and methods, read LDLogger.You can use basicLogger for simpler control over logging behavior. Versions 5.x and earlier of the SDK do not support basicLogger.This example shows how to use basicLogger to enable debug-level logging in your SDK configuration:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly users you create when you use this SDK.
PHP
Expand PHP code sample
Expand PHP code sample
LaunchDarkly.There are two important things to consider before you enable the DEBUG log level:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
logger property:Python
Expand Python code sample
Expand Python code sample
- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly users you create when you use this SDK.
Ruby
Expand Ruby code sample
Expand Ruby code sample
[LDClient].There are two important things to consider before you enable the DEBUG log level:- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
-
Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
You can pass a custom logger to the SDK by using the configurable
loggerproperty:
Rust
Expand Rust code sample
Expand Rust code sample
- Debug-level logs can be very verbose. We do not recommend using debug logging in high-volume environments.
- Debug-level logs include sensitive information, including LaunchDarkly contexts you create when you use this SDK.
Edge SDKs
This feature is available in the following edge SDKs:Cloudflare
Expand Cloudflare code sample
Expand Cloudflare code sample
Fastly
Expand Fastly code sample
Expand Fastly code sample
BasicLogger.Vercel
Expand Vercel code sample
Expand Vercel code sample
LDLogger interface. To learn more about the logger’s requirements and methods, read LDLogger.