Class Log4J2LoggingSystem


public class Log4J2LoggingSystem extends AbstractLoggingSystem
Since:
1.2.0
  • Constructor Details

    • Log4J2LoggingSystem

      public Log4J2LoggingSystem(ClassLoader classLoader)
  • Method Details

    • getStandardConfigLocations

      protected String[] getStandardConfigLocations()
      Description copied from class: AbstractLoggingSystem
      Return the standard config locations for this system.
      Specified by:
      getStandardConfigLocations in class AbstractLoggingSystem
      Returns:
      the standard config locations
      See Also:
    • isClassAvailable

      protected boolean isClassAvailable(String className)
    • beforeInitialize

      public void beforeInitialize()
      Description copied from class: LoggingSystem
      Reset the logging system to be limit output. This method may be called before LoggingSystem.initialize(LoggingInitializationContext, String, LogFile) to reduce logging noise until the system has been fully initialized.
      Overrides:
      beforeInitialize in class AbstractLoggingSystem
    • initialize

      public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile)
      Description copied from class: LoggingSystem
      Fully initialize the logging system.
      Overrides:
      initialize in class AbstractLoggingSystem
      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
    • loadDefaults

      protected void loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile)
      Description copied from class: AbstractLoggingSystem
      Load sensible defaults for the logging system.
      Specified by:
      loadDefaults in class AbstractLoggingSystem
      Parameters:
      initializationContext - the logging initialization context
      logFile - the file to load or null 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.
      Specified by:
      loadConfiguration in class AbstractLoggingSystem
      Parameters:
      initializationContext - the logging initialization context
      location - the location of the configuration to load (never null)
      logFile - the file to load or null if no log file is to be written
    • loadConfiguration

      protected void loadConfiguration(String location, LogFile logFile, List<String> overrides)
      Load the configuration from the given location, creating a composite using the configuration from the given overrides.
      Parameters:
      location - the location
      logFile - log file configuration
      overrides - the overriding locations
      Since:
      2.6.0
    • reinitialize

      protected void reinitialize(LoggingInitializationContext initializationContext)
      Description copied from class: AbstractLoggingSystem
      Reinitialize the logging system if required. Called when AbstractLoggingSystem.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 class AbstractLoggingSystem
      Parameters:
      initializationContext - the logging initialization context
    • getSupportedLogLevels

      public Set<LogLevel> getSupportedLogLevels()
      Description copied from class: LoggingSystem
      Returns a set of the LogLevels that are actually supported by the logging system.
      Overrides:
      getSupportedLogLevels in class LoggingSystem
      Returns:
      the supported levels
    • setLogLevel

      public void setLogLevel(String loggerName, LogLevel logLevel)
      Description copied from class: LoggingSystem
      Sets the logging level for a given logger.
      Overrides:
      setLogLevel in class LoggingSystem
      Parameters:
      loggerName - the name of the logger to set (null can be used for the root logger).
      logLevel - 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()
      Description copied from class: LoggingSystem
      Returns a collection of the current configuration for all a LoggingSystem's loggers.
      Overrides:
      getLoggerConfigurations in class LoggingSystem
      Returns:
      the current configurations
    • getLoggerConfiguration

      public LoggerConfiguration getLoggerConfiguration(String loggerName)
      Description copied from class: LoggingSystem
      Returns the current configuration for a LoggingSystem's logger.
      Overrides:
      getLoggerConfiguration in class LoggingSystem
      Parameters:
      loggerName - the name of the logger
      Returns:
      the current configuration
    • getShutdownHandler

      public Runnable getShutdownHandler()
      Description copied from class: LoggingSystem
      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.
      Overrides:
      getShutdownHandler in class LoggingSystem
      Returns:
      the shutdown handler, or null
    • 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 class LoggingSystem
    • getDefaultLogCorrelationPattern

      protected String getDefaultLogCorrelationPattern()
      Description copied from class: AbstractLoggingSystem
      Return the default log correlation pattern or null if log correlation patterns are not supported.
      Overrides:
      getDefaultLogCorrelationPattern in class AbstractLoggingSystem
      Returns:
      the default log correlation pattern
    • getEnvironment

      public static org.springframework.core.env.Environment getEnvironment(org.apache.logging.log4j.core.LoggerContext loggerContext)
      Get the Spring Environment attached to the given LoggerContext or null if no environment is available.
      Parameters:
      loggerContext - the logger context
      Returns:
      the Spring Environment or null
      Since:
      3.0.0