Class LogbackLoggingSystem
- java.lang.Object
- org.springframework.boot.logging.LoggingSystem
- org.springframework.boot.logging.AbstractLoggingSystem
- org.springframework.boot.logging.Slf4JLoggingSystem
- org.springframework.boot.logging.logback.LogbackLoggingSystem
public class LogbackLoggingSystem extends Slf4JLoggingSystem
LoggingSystem
for logback.
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.boot.logging.AbstractLoggingSystem
AbstractLoggingSystem.LogLevels<T>
Field Summary
Fields inherited from class org.springframework.boot.logging.AbstractLoggingSystem
CONFIGURATION_COMPARATOR
Fields inherited from class org.springframework.boot.logging.LoggingSystem
NONE, ROOT_LOGGER_NAME, SYSTEM_PROPERTY
Constructor Summary
Constructors Constructor Description LogbackLoggingSystem(ClassLoader classLoader)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beforeInitialize()
Reset the logging system to be limit output.void
cleanUp()
Clean up the logging system.LoggerConfiguration
getLoggerConfiguration(String loggerName)
Returns the current configuration for aLoggingSystem
's logger.List<LoggerConfiguration>
getLoggerConfigurations()
Returns a collection of the current configuration for all aLoggingSystem
's loggers.Runnable
getShutdownHandler()
Returns aRunnable
that can handle shutdown of this logging system when the JVM exits.protected String[]
getStandardConfigLocations()
Return the standard config locations for this system.Set<LogLevel>
getSupportedLogLevels()
Returns a set of theLogLevels
that are actually supported by the logging system.void
initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile)
Fully initialize the logging system.protected void
loadConfiguration(LoggingInitializationContext initializationContext, String location, LogFile logFile)
Load a specific configuration.protected void
loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile)
Load sensible defaults for the logging system.protected void
reinitialize(LoggingInitializationContext initializationContext)
Reinitialize the logging system if required.void
setLogLevel(String loggerName, LogLevel level)
Sets the logging level for a given logger.Methods inherited from class org.springframework.boot.logging.Slf4JLoggingSystem
isBridgeHandlerAvailable, isBridgeJulIntoSlf4j
Methods inherited from class org.springframework.boot.logging.AbstractLoggingSystem
applySystemProperties, getClassLoader, getPackagedConfigFile, getSelfInitializationConfig, getSpringConfigLocations, getSpringInitializationConfig
Methods inherited from class org.springframework.boot.logging.LoggingSystem
get
Constructor Detail
LogbackLoggingSystem
public LogbackLoggingSystem(ClassLoader classLoader)
Method Detail
getStandardConfigLocations
protected String[] getStandardConfigLocations()
Description copied from class:AbstractLoggingSystem
Return the standard config locations for this system.- Specified by:
getStandardConfigLocations
in classAbstractLoggingSystem
- Returns:
- the standard config locations
- See Also:
AbstractLoggingSystem.getSelfInitializationConfig()
beforeInitialize
public void beforeInitialize()
Description copied from class:LoggingSystem
Reset the logging system to be limit output. This method may be called beforeLoggingSystem.initialize(LoggingInitializationContext, String, LogFile)
to reduce logging noise until the system has been fully initialized.- Overrides:
beforeInitialize
in classSlf4JLoggingSystem
initialize
public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile)
Description copied from class:LoggingSystem
Fully initialize the logging system.- Overrides:
initialize
in classAbstractLoggingSystem
- Parameters:
initializationContext
- the logging initialization contextconfigLocation
- a log configuration location ornull
if default initialization is requiredlogFile
- the log output file that should be written ornull
for console only output
loadDefaults
protected void loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile)
Description copied from class:AbstractLoggingSystem
Load sensible defaults for the logging system.- Specified by:
loadDefaults
in classAbstractLoggingSystem
- Parameters:
initializationContext
- the logging initialization contextlogFile
- the file to load ornull
if no log file is to be written
loadConfiguration
protected void loadConfiguration(LoggingInitializationContext initializationContext, String location, LogFile logFile)
Description copied from class:AbstractLoggingSystem
Load a specific configuration.- Overrides:
loadConfiguration
in classSlf4JLoggingSystem
- Parameters:
initializationContext
- the logging initialization contextlocation
- the location of the configuration to load (nevernull
)logFile
- the file to load ornull
if no log file is to be written
cleanUp
public void cleanUp()
Description copied from class:LoggingSystem
Clean up the logging system. The default implementation does nothing. Subclasses should override this method to perform any logging system-specific cleanup.- Overrides:
cleanUp
in classSlf4JLoggingSystem
reinitialize
protected void reinitialize(LoggingInitializationContext initializationContext)
Description copied from class:AbstractLoggingSystem
Reinitialize the logging system if required. Called whenAbstractLoggingSystem.getSelfInitializationConfig()
is used and the log file hasn't changed. May be used to reload configuration (for example to pick up additional System properties).- Overrides:
reinitialize
in classAbstractLoggingSystem
- Parameters:
initializationContext
- the logging initialization context
getLoggerConfigurations
public List<LoggerConfiguration> getLoggerConfigurations()
Description copied from class:LoggingSystem
Returns a collection of the current configuration for all aLoggingSystem
's loggers.- Overrides:
getLoggerConfigurations
in classLoggingSystem
- Returns:
- the current configurations
getLoggerConfiguration
public LoggerConfiguration getLoggerConfiguration(String loggerName)
Description copied from class:LoggingSystem
Returns the current configuration for aLoggingSystem
's logger.- Overrides:
getLoggerConfiguration
in classLoggingSystem
- Parameters:
loggerName
- the name of the logger- Returns:
- the current configuration
getSupportedLogLevels
public Set<LogLevel> getSupportedLogLevels()
Description copied from class:LoggingSystem
Returns a set of theLogLevels
that are actually supported by the logging system.- Overrides:
getSupportedLogLevels
in classLoggingSystem
- Returns:
- the supported levels
setLogLevel
public void setLogLevel(String loggerName, LogLevel level)
Description copied from class:LoggingSystem
Sets the logging level for a given logger.- Overrides:
setLogLevel
in classLoggingSystem
- Parameters:
loggerName
- the name of the logger to set (null
can be used for the root logger).level
- the log level (null
can be used to remove any custom level for the logger and use the default configuration instead)
getShutdownHandler
public Runnable getShutdownHandler()
Description copied from class:LoggingSystem
Returns aRunnable
that can handle shutdown of this logging system when the JVM exits. The default implementation returnsnull
, indicating that no shutdown is required.- Overrides:
getShutdownHandler
in classLoggingSystem
- Returns:
- the shutdown handler, or
null