Package org.springframework.boot.logging
Class LoggingSystem
java.lang.Object
org.springframework.boot.logging.LoggingSystem
- Direct Known Subclasses:
AbstractLoggingSystem
Common abstraction over logging systems.
- Since:
- 1.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The value of theSYSTEM_PROPERTY
that can be used to indicate that noLoggingSystem
should be used.static final String
The name used for the root logger.static final String
A System property that can be used to indicate theLoggingSystem
to use. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Reset the logging system to be limit output.void
cleanUp()
Clean up the logging system.static LoggingSystem
get
(ClassLoader classLoader) Detect and return the logging system in use.getLoggerConfiguration
(String loggerName) Returns the current configuration for aLoggingSystem
's logger.Returns a collection of the current configuration for all aLoggingSystem
's loggers.Returns aRunnable
that can handle shutdown of this logging system when the JVM exits.Returns a set of theLogLevels
that are actually supported by the logging system.getSystemProperties
(org.springframework.core.env.ConfigurableEnvironment environment) Return theLoggingSystemProperties
that should be applied.void
initialize
(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile) Fully initialize the logging system.void
setLogLevel
(String loggerName, LogLevel level) Sets the logging level for a given logger.
-
Field Details
-
SYSTEM_PROPERTY
A System property that can be used to indicate theLoggingSystem
to use. -
NONE
The value of theSYSTEM_PROPERTY
that can be used to indicate that noLoggingSystem
should be used.- See Also:
-
ROOT_LOGGER_NAME
The name used for the root logger. LoggingSystem implementations should ensure that this is the name used to represent the root logger, regardless of the underlying implementation.- See Also:
-
-
Constructor Details
-
LoggingSystem
public LoggingSystem()
-
-
Method Details
-
getSystemProperties
public LoggingSystemProperties getSystemProperties(org.springframework.core.env.ConfigurableEnvironment environment) Return theLoggingSystemProperties
that should be applied.- Parameters:
environment
- theConfigurableEnvironment
used to obtain value- Returns:
- the
LoggingSystemProperties
to apply - Since:
- 2.4.0
-
beforeInitialize
public abstract void beforeInitialize()Reset the logging system to be limit output. This method may be called beforeinitialize(LoggingInitializationContext, String, LogFile)
to reduce logging noise until the system has been fully initialized. -
initialize
public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile) Fully initialize the logging system.- 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
-
cleanUp
public void cleanUp()Clean up the logging system. The default implementation does nothing. Subclasses should override this method to perform any logging system-specific cleanup. -
getShutdownHandler
Returns aRunnable
that can handle shutdown of this logging system when the JVM exits. The default implementation returnsnull
, indicating that no shutdown is required.- Returns:
- the shutdown handler, or
null
-
getSupportedLogLevels
Returns a set of theLogLevels
that are actually supported by the logging system.- Returns:
- the supported levels
-
setLogLevel
Sets the logging level for a given logger.- 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)
-
getLoggerConfigurations
Returns a collection of the current configuration for all aLoggingSystem
's loggers.- Returns:
- the current configurations
- Since:
- 1.5.0
-
getLoggerConfiguration
Returns the current configuration for aLoggingSystem
's logger.- Parameters:
loggerName
- the name of the logger- Returns:
- the current configuration
- Since:
- 1.5.0
-
get
Detect and return the logging system in use. Supports Logback and Java Logging.- Parameters:
classLoader
- the classloader- Returns:
- the logging system
-