org.springframework.boot.logging

Class LoggingSystem

  • java.lang.Object
    • org.springframework.boot.logging.LoggingSystem
  • Direct Known Subclasses:
    AbstractLoggingSystem


    public abstract class LoggingSystem
    extends java.lang.Object
    Common abstraction over logging systems.
    Since:
    1.0.0
    • Field Detail

      • SYSTEM_PROPERTY

        public static final java.lang.String SYSTEM_PROPERTY
        A System property that can be used to indicate the LoggingSystem to use.
      • ROOT_LOGGER_NAME

        public static final java.lang.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.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LoggingSystem

        public LoggingSystem()
    • Method Detail

      • initialize

        public void initialize(LoggingInitializationContext initializationContext,
                               java.lang.String configLocation,
                               LogFile logFile)
        Fully initialize the logging system.
        Parameters:
        initializationContext - the logging initialization context
        configLocation - a log configuration location or null if default initialization is required
        logFile - the log output file that should be written or null 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 java.lang.Runnable getShutdownHandler()
        Returns a Runnable that can handle shutdown of this logging system when the JVM exits. The default implementation returns null, indicating that no shutdown is required.
        Returns:
        the shutdown handler, or null
      • getSupportedLogLevels

        public java.util.Set<LogLevel> getSupportedLogLevels()
        Returns a set of the LogLevels that are actually supported by the logging system.
        Returns:
        the supported levels
      • setLogLevel

        public void setLogLevel(java.lang.String loggerName,
                                LogLevel level)
        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

        public java.util.List<LoggerConfiguration> getLoggerConfigurations()
        Returns a collection of the current configuration for all a LoggingSystem's loggers.
        Returns:
        the current configurations
        Since:
        1.5.0
      • getLoggerConfiguration

        public LoggerConfiguration getLoggerConfiguration(java.lang.String loggerName)
        Returns the current configuration for a LoggingSystem's logger.
        Parameters:
        loggerName - the name of the logger
        Returns:
        the current configuration
        Since:
        1.5.0
      • get

        public static LoggingSystem get(java.lang.ClassLoader classLoader)
        Detect and return the logging system in use. Supports Logback and Java Logging.
        Parameters:
        classLoader - the classloader
        Returns:
        the logging system