Class LoggerConfig


  • public class LoggerConfig
    extends Object
    The LoggerConfig allows to customize various aspects of the SDKs logging behavior.
    • Method Detail

      • fallbackToConsole

        public static LoggerConfig.Builder fallbackToConsole​(boolean fallbackToConsole)
        Use the console logger instead of the java.util.logging fallback in case SLF4J is not found or disabled. Please note that in addition setting this to true, either SLF4J must not be on the classpath or manually disabled via disableSlf4J(boolean) to make it work. By default, it will log at INFO level to stdout/stderr, but the loglevel can be configured via consoleLogLevel(Level).
        Parameters:
        fallbackToConsole - true if the console logger should be used as a fallback.
        Returns:
        a LoggerConfig.Builder for chaining purposes.
      • disableSlf4J

        public static LoggerConfig.Builder disableSlf4J​(boolean disableSlf4J)
        Disable SLF4J logging, which is by default the first option tried. If SLF4J is disabled, java.util.logging will be tried next, unless fallbackToConsole(boolean) is set to true.
        Parameters:
        disableSlf4J - set to true to disable SLF4J logging.
        Returns:
        a LoggerConfig.Builder for chaining purposes.
      • loggerName

        @Deprecated
        public static LoggerConfig.Builder loggerName​(String loggerName)
        Deprecated.
        the logging infrastructure picks the logger name automatically now based on the event type so it is easier to enable/disable logging or change the verbosity level for certain groups rather than having a single universal logger name.
        Allowed to set a custom logger name - does not have an effect and is deprecated.
        Parameters:
        loggerName - the custom logger name.
        Returns:
        a LoggerConfig.Builder for chaining purposes.
      • enableDiagnosticContext

        public static LoggerConfig.Builder enableDiagnosticContext​(boolean diagnosticContextEnabled)
        Enables the diagnostic context (if supported by the used logger) - disabled by default. Please note that this will only work for the SLF4J logger. Neither the java util logger, nor the console logger support the diagnostic context at this point. In SLF4J parlance, it is called the MDC.
        Parameters:
        diagnosticContextEnabled - if the diagnostic context should be enabled.
        Returns:
        a LoggerConfig.Builder for chaining purposes.
      • consoleLogLevel

        public static LoggerConfig.Builder consoleLogLevel​(Level consoleLogLevel)
        Allows to customize the log level for the Console Logger. Please note that this DOES NOT AFFECT any other logging infrastructure (so neither the java.util.logging, nor the SLF4J setup which is the default!). It will only affect the log level if fallbackToConsole(boolean) is set to true at the same time.
        Parameters:
        consoleLogLevel - the log level for the console logger.
        Returns:
        a LoggerConfig.Builder for chaining purposes.
      • consoleLoggerFormatter

        public LoggerConfig.Builder consoleLoggerFormatter​(LoggerFormatter loggerFormatter)
        Allows to customize the format when the console logger is used. Please note that this DOES NOT AFFECT any other logging infrastructure (so neither the java.util.logging, nor the SLF4J setup which is the default!). It will only affect the log level if fallbackToConsole(boolean) is set to true at the same time.

        If only a custom timestamp needs to be added, it is recommended to override the DefaultLoggerFormatter for ease of use. If a completely custom line is needed, the interface can be implemented from scratch.

        Parameters:
        loggerFormatter - the custom formatter to be used.
        Returns:
        a LoggerConfig.Builder for chaining purposes.
      • fallbackToConsole

        public boolean fallbackToConsole()
        Returns true if the console fallback is activated.
      • disableSlf4J

        public boolean disableSlf4J()
        Returns true if SLF4J should not be used, even if found on the classpath.
      • loggerName

        @Deprecated
        public String loggerName()
        Deprecated.
        Returns the custom logger name to use, deprecated.
      • diagnosticContextEnabled

        public boolean diagnosticContextEnabled()
        Returns true if the diagnostic context is enabled (disabled by default).
      • consoleLogLevel

        public Level consoleLogLevel()
        Returns the log level that should be used if the ConsoleLogger is enabled/used.
        Returns:
        the log level for the console logger.
      • consoleLoggerFormatter

        public LoggerFormatter consoleLoggerFormatter()
        Returns the logger formatter used for the console logger.
        Returns:
        the logger formatter.