Contains methods for configuring the SDK's logging behavior.
public sealed class LoggingConfigurationBuilder : Object
If you want to set non-default values for any of these properties, create a builder with Logging(), change its properties with the methods of this class, and pass it to Logging(LoggingConfigurationBuilder).
The default behavior, if you do not change any properties, depends on the runtime platform:
By default, the minimum log level is
Info (that is,
Debug logging is
disabled). This can be overridden with Level(LogLevel).
The base logger name is normally
LaunchDarkly.Sdk (on iOS, this corresponds to a
"subsystem" name of "LaunchDarkly" and a "category" name of "Sdk"). See BaseLoggerName(String)
for more about logger names and how to change the name.
var config = Configuration.Builder("my-sdk-key") .Logging(Components.Logging().Level(LogLevel.Warn)) .Build();
Creates a new builder with default properties.
Specifies the implementation of logging to use.
public LoggingConfigurationBuilder Adapter(ILogAdapter adapter)
the same builder
LaunchDarkly.Logging API defines the
ILogAdapter interface to specify where log output should be sent. By default, it is set to
Logs.ToConsole, meaning that output will be sent to
Console.Error. You may use other
LaunchDarkly.Logging.Logs methods, or a custom implementation, to handle log output differently.
Logs.None disables logging (equivalent to NoLogging).
For more about logging adapters, see the API
If you don't need to customize any options other than the adapter, you can call Logging(ILogAdapter) as a shortcut rather than using LoggingConfigurationBuilder.
// This example configures the SDK to send log output to a file writer. var writer = File.CreateText("sdk.log"); var config = Configuration.Builder("my-sdk-key") .Logging(Components.Logging().Adapter(Logs.ToWriter(writer))) .Build();
Specifies a custom base logger name.
public LoggingConfigurationBuilder BaseLoggerName(string baseLoggerName)
the same builder
Logger names are used to give context to the log output, indicating that it is from the LaunchDarkly SDK instead of another component, or indicating a more specific area of functionality within the SDK. The default console logging implementation shows the logger name in brackets, for instance:
[LaunchDarkly.Sdk.DataSource] INFO: Reconnected to LaunchDarkly stream
If you are using an adapter for a third-party logging framework (see Adapter(ILogAdapter)), most frameworks have a mechanism for filtering log output by the logger name.
By default, the SDK uses a base logger name of
LaunchDarkly.Sdk. Messages will be
logged either under this name, or with a suffix to indicate what general area of
functionality is involved:
BaseLoggerName to a non-null value overrides the default. The SDK still
adds the same suffixes to the name, so for instance if you set it to
example message above would show
When using the default logging framework in iOS, logger names are handled slightly
differently because iOS's
OSLog has two kinds of logger names: a general
"subsystem", and a more specific "category". The SDK handles this by taking everything
after the first period in the logger name as the category: for instance, for
LaunchDarkly.Sdk.DataSource, the subsystem is
LaunchDarkly and the category
Sdk.DataSource. If you set a custom base logger name, the same rules apply, so
for instance if you set it to
"LD" then then
LD.DataSource would become
a subsystem of
LD and a category of
Called internally by the SDK to create a configuration instance. Applications do not need to call this method.
public LoggingConfiguration CreateLoggingConfiguration()
the logging configuration
Specifies the lowest level of logging to enable.
public LoggingConfigurationBuilder Level(LogLevel minimumLevel)
the lowest level of logging to enable
the same builder
This adds a log level filter that is applied regardless of what implementation of logging is
being used, so that log messages at lower levels are suppressed. For instance, setting the
minimum level to LaunchDarkly.Logging.LogLevel.Info means that
Debug-level output is disabled.
External logging frameworks may also have their own mechanisms for setting a minimum log level.
If you did not specify an LaunchDarkly.Logging.ILogAdapter at all, so it is using the default
destination, then the default minimum logging level is
If you did specify an LaunchDarkly.Logging.ILogAdapter, then the SDK does not apply a level filter by default. This is so as not to interfere with any other configuration that you may have set up in an external logging framework. However, you can still use this method to set a higher level so that any messages below that level will not be sent to the external framework at all.