Class Loggers
java.util.logging.Logger). By default, the Console
fallback is used. To use the JDK loggers, set the "reactor.logging.fallback"
System property to "JDK".
One can also force the implementation by using the "useXXX" static methods:
useConsoleLoggers(), useVerboseConsoleLoggers(), useJdkLoggers()
and useSl4jLoggers() (which may throw an Exception if the library isn't on the
classpath). Note that the system property method above is preferred, as no cleanup of
the logger factory initialized at startup is attempted by the useXXX methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe system property that determines which fallback implementation to use for loggers when SLF4J isn't available. -
Method Summary
Modifier and TypeMethodDescriptionstatic LoggerGet aLogger, backed by SLF4J if present on the classpath or falling back tojava.util.logging.Logger.static LoggerGet aLogger.static voidAttempt to activate the bestreactor Loggerfactory, by first attempting to use the SLF4J one, then falling back to either Console logging orjava.util.logging.Logger).static voidForce the usage of Console-basedLoggers, even if SLF4J is available on the classpath.static voiduseCustomLoggers(Function<String, ? extends Logger> loggerFactory) static voidForce the usage of JDK-basedLoggers, even if SLF4J is available on the classpath.static voidForce the usage of SL4J-basedLoggers, throwing an exception if SLF4J isn't available on the classpath.static voidForce the usage of Console-basedLoggers, even if SLF4J is available on the classpath.
-
Field Details
-
FALLBACK_PROPERTY
The system property that determines which fallback implementation to use for loggers when SLF4J isn't available. UseJDKfor the JDK-backed logging and anything else for Console-based (the default).- See Also:
-
-
Method Details
-
resetLoggerFactory
public static void resetLoggerFactory()Attempt to activate the bestreactor Loggerfactory, by first attempting to use the SLF4J one, then falling back to either Console logging orjava.util.logging.Logger). By default, the Console fallback is used. To fallback to the JDK loggers, set the "reactor.logging.fallback"System propertyto "JDK". -
useConsoleLoggers
public static void useConsoleLoggers()Force the usage of Console-basedLoggers, even if SLF4J is available on the classpath. Console loggers will outputERRORandWARNlevels toSystem.errand levels below toSystem.out. All levels except TRACE and DEBUG are considered enabled. TRACE and DEBUG are omitted.The previously active logger factory is simply replaced without any particular clean-up.
-
useVerboseConsoleLoggers
public static void useVerboseConsoleLoggers()Force the usage of Console-basedLoggers, even if SLF4J is available on the classpath. Console loggers will outputERRORandWARNlevels toSystem.errand levels below toSystem.out. All levels (including TRACE and DEBUG) are considered enabled.The previously active logger factory is simply replaced without any particular clean-up.
-
useCustomLoggers
Use a custom type ofLoggercreated through the providedFunction, which takes a logger name as input.The previously active logger factory is simply replaced without any particular clean-up.
Thread-safety
Given logger acquisition function must be thread-safe. It means that it is user responsibility to ensure that any internal state and cache used by the provided function is properly synchronized. -
useJdkLoggers
public static void useJdkLoggers()Force the usage of JDK-basedLoggers, even if SLF4J is available on the classpath.The previously active logger factory is simply replaced without any particular clean-up.
-
useSl4jLoggers
public static void useSl4jLoggers()Force the usage of SL4J-basedLoggers, throwing an exception if SLF4J isn't available on the classpath. Prefer usingresetLoggerFactory()as it will fallback in the later case.The previously active logger factory is simply replaced without any particular clean-up.
-
getLogger
Get aLogger.For a notion of how the backing implementation is chosen, see
resetLoggerFactory()(or call one of theuseXxxLoggersmethods).- Parameters:
name- the category or logger name to use- Returns:
- a new
Loggerinstance
-
getLogger
Get aLogger, backed by SLF4J if present on the classpath or falling back tojava.util.logging.Logger.
-