Package com.couchbase.client.core.env
Class LoggerConfig.Builder
- java.lang.Object
-
- com.couchbase.client.core.env.LoggerConfig.Builder
-
- Enclosing class:
- LoggerConfig
public static class LoggerConfig.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LoggerConfig
build()
Builds theLoggerConfig
and makes it immutable.LoggerConfig.Builder
consoleLoggerFormatter(LoggerFormatter loggerFormatter)
Allows to customize the format when the console logger is used.LoggerConfig.Builder
consoleLogLevel(Level consoleLogLevel)
Allows to customize the log level for the Console Logger.LoggerConfig.Builder
customLogger(LoggingEventConsumer.Logger customLogger)
Allows to specify a custom logger.LoggerConfig.Builder
disableSlf4J(boolean disableSlf4J)
Disable SLF4J logging, which is by default the first option tried.LoggerConfig.Builder
enableDiagnosticContext(boolean diagnosticContextEnabled)
Enables the diagnostic context (if supported by the used logger) - disabled by default.LoggerConfig.Builder
fallbackToConsole(boolean fallbackToConsole)
Use the console logger instead of the java.util.logging fallback in case SLF4J is not found or disabled.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.
-
-
-
Method Detail
-
customLogger
@Internal public LoggerConfig.Builder customLogger(LoggingEventConsumer.Logger customLogger)
Allows to specify a custom logger. This is used for testing only.- Parameters:
customLogger
- the custom logger- Returns:
- this
LoggerConfig.Builder
for chaining purposes.
-
fallbackToConsole
public 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 viadisableSlf4J(boolean)
to make it work. By default, it will log at INFO level to stdout/stderr, but the loglevel can be configured viaconsoleLogLevel(Level)
.- Parameters:
fallbackToConsole
- true if the console logger should be used as a fallback.- Returns:
- this
LoggerConfig.Builder
for chaining purposes.
-
disableSlf4J
public 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, unlessfallbackToConsole(boolean)
is set to true.- Parameters:
disableSlf4J
- set to true to disable SLF4J logging.- Returns:
- this
LoggerConfig.Builder
for chaining purposes.
-
loggerName
@Deprecated public 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:
- this
LoggerConfig.Builder
for chaining purposes.
-
enableDiagnosticContext
public 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:
- this
LoggerConfig.Builder
for chaining purposes.
-
consoleLogLevel
public 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 iffallbackToConsole(boolean)
is set to true at the same time.- Parameters:
consoleLogLevel
- the log level for the console logger.- Returns:
- this
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 iffallbackToConsole(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:
- this
LoggerConfig.Builder
for chaining purposes.
-
build
public LoggerConfig build()
Builds theLoggerConfig
and makes it immutable.- Returns:
- the built, immutable logger config.
-
-