Spring Boot for VMware GemFire
Class LogbackSupport
java.lang.Object
org.springframework.geode.logging.slf4j.logback.support.LogbackSupport
Abstract utility class containing functionality for invoking SLF4J and Logback APIs.
- Since:
- 1.3.0
- See Also:
-
ILoggerFactoryLoggerLoggerFactoryLoggerContextAppender
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddAppender(ch.qos.logback.classic.Logger logger, ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender) Adds the givenAppenderto the givenLogger.static booleanremoveAppender(ch.qos.logback.classic.Logger logger, String appenderName) static booleanremoveConsoleAppender(ch.qos.logback.classic.Logger logger) Removes the consoleAppenderfrom the givenLogger.static booleanremoveDelegateAppender(ch.qos.logback.classic.Logger logger) Removes the delegateAppenderfrom the givenLogger.static <E,T extends ch.qos.logback.core.Appender<E>>
TrequireAppender(ch.qos.logback.classic.Logger logger, String appenderName, Class<T> appenderType) static ch.qos.logback.classic.LoggerRequires the SLF4J Logback ROOTLoggerotherwise throws anIllegalStateException.static ch.qos.logback.classic.LoggerContextRequires aLoggerContextotherwise throws anIllegalStateException.static voidResets the state of the SLF4J Logback logging provider and system.static <E,T extends ch.qos.logback.core.Appender<E>>
Optional<T>resolveAppender(ch.qos.logback.classic.Logger logger, String appenderName, Class<T> appenderType) static Optional<ch.qos.logback.classic.LoggerContext>Resolves the SLF4J, LogbackLoggerContext.static Optional<org.slf4j.Logger>Resolves theRootLogger.static voidProperly stops Logback classic.static voidDisables Spring Boot's logging initialization, auto-configuration.static Optional<ch.qos.logback.classic.Logger>toLogbackLogger(org.slf4j.Logger logger) Converts an SLF4JLoggerto a LogbackLogger.
-
Field Details
-
slf4jLoggerToLogbackLoggerConverter
-
CONSOLE_APPENDER_NAME
- See Also:
-
DELEGATE_APPENDER_NAME
- See Also:
-
ILLEGAL_LOGGER_TYPE_EXCEPTION_MESSAGE
- See Also:
-
ROOT_LOGGER_NAME
- See Also:
-
SPRING_BOOT_LOGGING_SYSTEM_CLASS_NAME
- See Also:
-
UNRESOLVABLE_APPENDER_EXCEPTION_MESSAGE
- See Also:
-
-
Constructor Details
-
LogbackSupport
public LogbackSupport()
-
-
Method Details
-
suppressSpringBootLogbackInitialization
public static void suppressSpringBootLogbackInitialization()Disables Spring Boot's logging initialization, auto-configuration. -
stopLogback
public static void stopLogback()Properly stops Logback classic.- See Also:
-
resetLogback
public static void resetLogback()Resets the state of the SLF4J Logback logging provider and system. -
resolveLoggerContext
Resolves the SLF4J, LogbackLoggerContext. If theLoggerContextcould not be resolve then the returnedOptionalwill beempty.- Returns:
- an
OptionalLoggerContext. - See Also:
-
LoggerContext
-
requireLoggerContext
public static ch.qos.logback.classic.LoggerContext requireLoggerContext()Requires aLoggerContextotherwise throws anIllegalStateException.- Returns:
- the required
LoggerContext. - Throws:
IllegalStateException- if theLoggerContextcould not be resolved.- See Also:
-
resolveRootLogger
Resolves theRootLogger.- Returns:
- an
OptionalLoggerfor the logging provider's ROOTLogger. - See Also:
-
Logger
-
requireLogbackRootLogger
public static ch.qos.logback.classic.Logger requireLogbackRootLogger()Requires the SLF4J Logback ROOTLoggerotherwise throws anIllegalStateException.- Returns:
- the configured SLF4J Logback ROOT
Logger. - Throws:
IllegalStateException- if the SLF4J Logback ROOTLoggercould not be resolved or the ROOTLoggeris not a SLF4J Logback ROOTLogger.- See Also:
-
LoggerresolveRootLogger()
-
resolveAppender
public static <E,T extends ch.qos.logback.core.Appender<E>> Optional<T> resolveAppender(ch.qos.logback.classic.Logger logger, String appenderName, Class<T> appenderType) - Type Parameters:
T-typeof theAppender.E-typeof the logging event.- Parameters:
logger- SLF4JLoggerfrom which to resolve theAppender.appenderName- aStringcontaining the name of theAppenderto resolve.appenderType- requiredtypeof theAppenderto resolve.- Returns:
- an
OptionalAppenderwith the givennamefrom theLogger. - See Also:
-
AppenderOptionalLogger
-
requireAppender
public static <E,T extends ch.qos.logback.core.Appender<E>> T requireAppender(ch.qos.logback.classic.Logger logger, String appenderName, Class<T> appenderType) - Type Parameters:
T-typeof theAppender.E-typeof theObjectsprocessed by theAppender.- Parameters:
logger-Loggerfrom which to resolve theAppender.appenderName-Stringcontaining the name of theAppender.appenderType- requiredtypeof theAppender.- Returns:
- the resolved
Appender. - Throws:
IllegalStateException- if anAppenderwithnameand requiredtypecould not be resolved from the givenLogger.- See Also:
-
LoggerAppender
-
addAppender
public static boolean addAppender(ch.qos.logback.classic.Logger logger, ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender) Adds the givenAppenderto the givenLogger.- Parameters:
logger-Loggerto add theAppenderto.appender-Appenderto add to theLogger.- Returns:
- a boolean value indicating whether the
Appenderwas successfully added to theLogger. - See Also:
-
LoggerAppender
-
removeAppender
- Parameters:
logger-Loggerfrom which to remove theAppender.appenderName-nameof theAppenderto remove from theLogger.- Returns:
- a boolean value indicating whether the targeted
Appenderwas removed from the givenLogger. - See Also:
-
LoggerAppender
-
removeConsoleAppender
public static boolean removeConsoleAppender(ch.qos.logback.classic.Logger logger) Removes the consoleAppenderfrom the givenLogger.- Parameters:
logger-Loggerfrom which to remove the consoleAppender.- Returns:
- true if the console
Appenderwas registered with and successfully remove from the givenLogger. - See Also:
-
removeDelegateAppender
public static boolean removeDelegateAppender(ch.qos.logback.classic.Logger logger) Removes the delegateAppenderfrom the givenLogger.- Parameters:
logger-Loggerfrom which to remove the delegateAppender.- Returns:
- true if the delegate
Appenderwas registered with and successfully remove from the givenLogger. - See Also:
-
toLogbackLogger
Converts an SLF4JLoggerto a LogbackLogger.
-