Class LoggingConfigurationBuilder

    • Field Detail

      • DEFAULT_LOG_DATA_SOURCE_OUTAGE_AS_ERROR_AFTER

        public static final java.time.Duration DEFAULT_LOG_DATA_SOURCE_OUTAGE_AS_ERROR_AFTER
        The default value for logDataSourceOutageAsErrorAfter(Duration): one minute.
      • baseName

        protected java.lang.String baseName
      • logDataSourceOutageAsErrorAfter

        protected java.time.Duration logDataSourceOutageAsErrorAfter
    • Constructor Detail

      • LoggingConfigurationBuilder

        public LoggingConfigurationBuilder()
    • Method Detail

      • baseLoggerName

        public LoggingConfigurationBuilder baseLoggerName​(java.lang.String name)
        Specifies a custom base logger name.

        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. Many logging implementations show the logger name in in brackets, for instance:

        
             [com.launchdarkly.sdk.LDClient] INFO: Reconnected to LaunchDarkly stream
         

        If you are using an adapter for a third-party logging framework such as SLF4J (see adapter(LDLogAdapter)), most frameworks have a mechanism for filtering log output by the logger name.

        By default, the SDK uses a base logger name of com.launchdarkly.sdk.LDClient. Messages will be logged either under this name, or with a suffix to indicate what general area of functionality is involved:

        • .DataSource: problems or status messages regarding how the SDK gets feature flag data from LaunchDarkly.
        • .DataStore: problems or status messages regarding how the SDK stores its feature flag data (for instance, if you are using a database).
        • .Evaluation: problems in evaluating a feature flag or flags, which were caused by invalid flag data or incorrect usage of the SDK rather than for instance a database problem.
        • .Events problems or status messages regarding the SDK's delivery of analytics event data to LaunchDarkly.

        Setting baseLoggerName(String) 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 "LD", the example message above would show [LD.DataSource].

        Parameters:
        name - the base logger name
        Returns:
        the builder
        Since:
        5.10.0
      • level

        public LoggingConfigurationBuilder level​(LDLogLevel minimumLevel)
        Specifies the lowest level of logging to enable.

        This is only applicable when using an implementation of logging that does not have its own external configuration mechanism, such as Logs.toConsole(). It adds a log level filter so that log messages at lower levels are suppressed. For instance, setting the minimum level to LDLogLevel.INFO means that DEBUG-level output is disabled. If not specified, the default minimum level is LDLogLevel.INFO.

        When using a logging framework like SLF4J or java.util.logging that has its own separate mechanism for log filtering, you must use that framework's configuration options for log levels; calling level(LDLogLevel) in that case has no effect.

        Parameters:
        minimumLevel - the lowest level of logging to enable
        Returns:
        the builder
        Since:
        5.10.0
      • logDataSourceOutageAsErrorAfter

        public LoggingConfigurationBuilder logDataSourceOutageAsErrorAfter​(java.time.Duration logDataSourceOutageAsErrorAfter)
        Sets the time threshold, if any, after which the SDK will log a data source outage at ERROR level instead of WARN level.

        A data source outage means that an error condition, such as a network interruption or an error from the LaunchDarkly service, is preventing the SDK from receiving feature flag updates. Many outages are brief and the SDK can recover from them quickly; in that case it may be undesirable to log an ERROR line, which might trigger an unwanted automated alert depending on your monitoring tools. So, by default, the SDK logs such errors at WARN level. However, if the amount of time specified by this method elapses before the data source starts working again, the SDK will log an additional message at ERROR level to indicate that this is a sustained problem.

        The default is DEFAULT_LOG_DATA_SOURCE_OUTAGE_AS_ERROR_AFTER. Setting it to null will disable this feature, so you will only get WARN messages.

        Parameters:
        logDataSourceOutageAsErrorAfter - the error logging threshold, or null
        Returns:
        the builder