Top Description Inners Fields Constructors Methods
reactor.util

public abstract Class Loggers

extends Object
Class Inheritance
Imports
java.io.PrintStream, java.lang.ref.WeakReference, java.util.Map, .Objects, .WeakHashMap, java.util.function.Function, java.util.logging.Level, java.util.regex.Matcher, reactor.util.annotation.Nullable

Expose static methods to get a logger depending on the environment. If SL4J is on the classpath, it will be used. Otherwise, there are two possible fallbacks: Console or 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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Loggers.ConsoleLogger

A Logger that has all levels enabled.

pack-priv static class
private static class
Loggers.ConsoleLoggerKey

A key object to serve a dual purpose:

  • Allow consistent identification of cached console loggers using not only its name, but also its verbosity level
  • Provide an object eligible to cache eviction. Contrary to a logger or a string (logger name) object, this is a good candidate for weak reference key, because it should be held only internally by the attached logger and by the logger cache (as evictable key).
pack-priv static class
Loggers.JdkLogger

Wrapper over JDK logger

private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
public static final String
FALLBACK_PROPERTY

The system property that determines which fallback implementation to use for loggers when SLF4J isn't available.

private static Function<String, ? extends Logger>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static Logger

Returns:

a new Logger instance
getLogger
(String
the category or logger name to use
name
)

Get a Logger.

public static Logger

Returns:

a new Logger instance
getLogger
(Class<?>
the source Class to derive the logger name from.
cls
)

Get a Logger, backed by SLF4J if present on the classpath or falling back to java.util.logging.Logger.

pack-priv static boolean

Returns:

true if falling back to JDK, false for Console.
isFallbackToJdk
()

Return true if resetLoggerFactory() would fallback to java.util.logging rather than console-based logging, as defined by the FALLBACK_PROPERTY System property.

public 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).

public static void
useConsoleLoggers()

Force the usage of Console-based Loggers, even if SLF4J is available on the classpath.

public static void
useCustomLoggers(final Function<String, ? extends Logger>
the Function that provides a (possibly cached) Logger given a name.
loggerFactory
)

Use a custom type of Logger created through the provided Function, which takes a logger name as input.

public static void
useJdkLoggers()

Force the usage of JDK-based Loggers, even if SLF4J is available on the classpath.

public static void
useSl4jLoggers()

Force the usage of SL4J-based Loggers, throwing an exception if SLF4J isn't available on the classpath.

public static void
useVerboseConsoleLoggers()

Force the usage of Console-based Loggers, even if SLF4J is available on the classpath.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait