Class LoggingSystem
java.lang.Object
org.springframework.boot.logging.LoggingSystem
- Direct Known Subclasses:
AbstractLoggingSystem
Common abstraction over logging systems.
- Since:
- 1.0.0
- Author:
- Phillip Webb, Dave Syer, Andy Wilkinson, Ben Hale
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of anEnvironmentproperty used to indicate that a correlation ID is expected to be logged at some point.static final StringThe value of theSYSTEM_PROPERTYthat can be used to indicate that noLoggingSystemshould be used.static final StringThe name used for the root logger.static final StringA System property that can be used to indicate theLoggingSystemto use. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidReset the logging system to be limit output.voidcleanUp()Clean up the logging system.static LoggingSystemget(ClassLoader classLoader) Detect and return the logging system in use.@Nullable LoggerConfigurationgetLoggerConfiguration(String loggerName) Returns the current configuration for aLoggingSystem's logger.Returns a collection of the current configuration for all aLoggingSystem's loggers.@Nullable RunnableReturns aRunnablethat can handle shutdown of this logging system when the JVM exits.Returns a set of theLogLevelsthat are actually supported by the logging system.getSystemProperties(ConfigurableEnvironment environment) Return theLoggingSystemPropertiesthat should be applied.voidinitialize(LoggingInitializationContext initializationContext, @Nullable String configLocation, @Nullable LogFile logFile) Fully initialize the logging system.voidsetLogLevel(@Nullable String loggerName, @Nullable LogLevel level) Sets the logging level for a given logger.
-
Field Details
-
SYSTEM_PROPERTY
A System property that can be used to indicate theLoggingSystemto use. -
NONE
The value of theSYSTEM_PROPERTYthat can be used to indicate that noLoggingSystemshould 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:
-
EXPECT_CORRELATION_ID_PROPERTY
The name of anEnvironmentproperty used to indicate that a correlation ID is expected to be logged at some point.- Since:
- 3.2.0
- See Also:
-
-
Constructor Details
-
LoggingSystem
public LoggingSystem()
-
-
Method Details
-
getSystemProperties
Return theLoggingSystemPropertiesthat should be applied.- Parameters:
environment- theConfigurableEnvironmentused to obtain value- Returns:
- the
LoggingSystemPropertiesto 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, @Nullable String configLocation, @Nullable LogFile logFile) Fully initialize the logging system.- Parameters:
initializationContext- the logging initialization contextconfigLocation- a log configuration location ornullif default initialization is requiredlogFile- the log output file that should be written ornullfor 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
-
getSupportedLogLevels
-
setLogLevel
Sets the logging level for a given logger.- Parameters:
loggerName- the name of the logger to set (nullcan be used for the root logger).level- the log level (nullcan 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
-