public abstract class Loggers extends Object
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.
Modifier and Type | Field and Description |
---|---|
static String |
FALLBACK_PROPERTY
The system property that determines which fallback implementation to use for loggers
when SLF4J isn't available.
|
Modifier and Type | Method and Description |
---|---|
static Logger |
getLogger(Class<?> cls)
Get a
Logger , backed by SLF4J if present on the classpath or falling back
to java.util.logging.Logger . |
static Logger |
getLogger(String name)
Get a
Logger . |
static void |
resetLoggerFactory()
Attempt to activate the best
reactor Logger factory, by first attempting
to use the SLF4J one, then falling back to either Console logging or
java.util.logging.Logger ). |
static void |
useConsoleLoggers()
Force the usage of Console-based
Loggers , even if SLF4J is available
on the classpath. |
static void |
useCustomLoggers(Function<String,? extends Logger> loggerFactory)
|
static void |
useJdkLoggers()
Force the usage of JDK-based
Loggers , even if SLF4J is available
on the classpath. |
static void |
useSl4jLoggers()
Force the usage of SL4J-based
Loggers , throwing an exception if
SLF4J isn't available on the classpath. |
static void |
useVerboseConsoleLoggers()
Force the usage of Console-based
Loggers , even if SLF4J is available
on the classpath. |
public static final String FALLBACK_PROPERTY
JDK
for the JDK-backed logging and anything
else for Console-based (the default).public static void resetLoggerFactory()
reactor Logger
factory, by first attempting
to use the SLF4J one, then falling back to either Console logging or
java.util.logging.Logger
). By default, the Console
fallback is used. To fallback to the JDK loggers, set the "reactor.logging.fallback"
System property
to "JDK
".public static void useConsoleLoggers()
Loggers
, even if SLF4J is available
on the classpath. Console loggers will output ERROR
and
WARN
levels to System.err
and levels below to
System.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.
public static void useVerboseConsoleLoggers()
Loggers
, even if SLF4J is available
on the classpath. Console loggers will output ERROR
and
WARN
levels to System.err
and levels below to
System.out
. All levels (including TRACE and DEBUG) are considered enabled.
The previously active logger factory is simply replaced without any particular clean-up.
public static void useCustomLoggers(Function<String,? extends Logger> loggerFactory)
public static void useJdkLoggers()
Loggers
, even if SLF4J is available
on the classpath.
The previously active logger factory is simply replaced without any particular clean-up.
public static void useSl4jLoggers()
Loggers
, throwing an exception if
SLF4J isn't available on the classpath. Prefer using resetLoggerFactory()
as it will fallback in the later case.
The previously active logger factory is simply replaced without any particular clean-up.
public static Logger getLogger(String name)
Logger
.
For a notion of how the backing implementation is chosen, see
resetLoggerFactory()
(or call one of the useXxxLoggers
methods).
name
- the category or logger name to useLogger
instance