类 LoggingSystem
- java.lang.Object
- org.springframework.boot.logging.LoggingSystem
- 直接已知子类:
AbstractLoggingSystem
public abstract class LoggingSystem extends Object
Common abstraction over logging systems.
字段概要
字段 修饰符和类型 字段 说明 static String
NONE
The value of theSYSTEM_PROPERTY
that can be used to indicate that noLoggingSystem
should be used.static String
ROOT_LOGGER_NAME
The name used for the root logger.static String
SYSTEM_PROPERTY
A System property that can be used to indicate theLoggingSystem
to use.
构造器概要
构造器 构造器 说明 LoggingSystem()
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 abstract void
beforeInitialize()
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.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.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.void
setLogLevel(String loggerName, LogLevel level)
Sets the logging level for a given logger.
字段详细资料
SYSTEM_PROPERTY
public static final String SYSTEM_PROPERTY
A System property that can be used to indicate theLoggingSystem
to use.
NONE
public static final String NONE
The value of theSYSTEM_PROPERTY
that can be used to indicate that noLoggingSystem
should be used.- 另请参阅:
- 常量字段值
ROOT_LOGGER_NAME
public static final String 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.- 另请参阅:
- 常量字段值
构造器详细资料
LoggingSystem
public LoggingSystem()
方法详细资料
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.- 参数:
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
public Runnable 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.- 返回:
- the shutdown handler, or
null
getSupportedLogLevels
public Set<LogLevel> getSupportedLogLevels()
Returns a set of theLogLevels
that are actually supported by the logging system.- 返回:
- the supported levels
setLogLevel
public void setLogLevel(String loggerName, LogLevel level)
Sets the logging level for a given logger.- 参数:
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
public List<LoggerConfiguration> getLoggerConfigurations()
Returns a collection of the current configuration for all aLoggingSystem
's loggers.- 返回:
- the current configurations
- 从以下版本开始:
- 1.5.0
getLoggerConfiguration
public LoggerConfiguration getLoggerConfiguration(String loggerName)
Returns the current configuration for aLoggingSystem
's logger.- 参数:
loggerName
- the name of the logger- 返回:
- the current configuration
- 从以下版本开始:
- 1.5.0
get
public static LoggingSystem get(ClassLoader classLoader)
Detect and return the logging system in use. Supports Logback and Java Logging.- 参数:
classLoader
- the classloader- 返回:
- the logging system