public class Log4J2LoggingSystem extends Slf4JLoggingSystem
LoggingSystem
for Log4j 2.Modifier and Type | Class and Description |
---|---|
static class |
Log4J2LoggingSystem.Factory
LoggingSystemFactory that returns Log4J2LoggingSystem if possible. |
AbstractLoggingSystem.LogLevels<T>
CONFIGURATION_COMPARATOR
NONE, ROOT_LOGGER_NAME, SYSTEM_PROPERTY
Constructor and Description |
---|
Log4J2LoggingSystem(java.lang.ClassLoader classLoader) |
Modifier and Type | Method and Description |
---|---|
void |
beforeInitialize()
Reset the logging system to be limit output.
|
void |
cleanUp()
Clean up the logging system.
|
LoggerConfiguration |
getLoggerConfiguration(java.lang.String loggerName)
Returns the current configuration for a
LoggingSystem 's logger. |
java.util.List<LoggerConfiguration> |
getLoggerConfigurations()
Returns a collection of the current configuration for all a
LoggingSystem 's
loggers. |
java.lang.Runnable |
getShutdownHandler()
Returns a
Runnable that can handle shutdown of this logging system when the
JVM exits. |
protected java.lang.String[] |
getStandardConfigLocations()
Return the standard config locations for this system.
|
java.util.Set<LogLevel> |
getSupportedLogLevels()
Returns a set of the
LogLevels that are actually supported by the
logging system. |
void |
initialize(LoggingInitializationContext initializationContext,
java.lang.String configLocation,
LogFile logFile)
Fully initialize the logging system.
|
protected boolean |
isClassAvailable(java.lang.String className) |
protected void |
loadConfiguration(LoggingInitializationContext initializationContext,
java.lang.String location,
LogFile logFile)
Load a specific configuration.
|
protected void |
loadConfiguration(java.lang.String location,
LogFile logFile)
Deprecated.
since 2.6.0 for removal in 3.0.0 in favor of
loadConfiguration(String, LogFile, List) |
protected void |
loadConfiguration(java.lang.String location,
LogFile logFile,
java.util.List<java.lang.String> overrides)
Load the configuration from the given
location , creating a composite using
the configuration from the given overrides . |
protected void |
loadDefaults(LoggingInitializationContext initializationContext,
LogFile logFile)
Load sensible defaults for the logging system.
|
protected void |
reinitialize(LoggingInitializationContext initializationContext)
Reinitialize the logging system if required.
|
void |
setLogLevel(java.lang.String loggerName,
LogLevel logLevel)
Sets the logging level for a given logger.
|
isBridgeHandlerAvailable, isBridgeJulIntoSlf4j
applySystemProperties, getClassLoader, getPackagedConfigFile, getSelfInitializationConfig, getSpringConfigLocations, getSpringInitializationConfig
get, getSystemProperties
public Log4J2LoggingSystem(java.lang.ClassLoader classLoader)
protected java.lang.String[] getStandardConfigLocations()
AbstractLoggingSystem
getStandardConfigLocations
in class AbstractLoggingSystem
AbstractLoggingSystem.getSelfInitializationConfig()
protected boolean isClassAvailable(java.lang.String className)
public void beforeInitialize()
LoggingSystem
LoggingSystem.initialize(LoggingInitializationContext, String, LogFile)
to reduce
logging noise until the system has been fully initialized.beforeInitialize
in class Slf4JLoggingSystem
public void initialize(LoggingInitializationContext initializationContext, java.lang.String configLocation, LogFile logFile)
LoggingSystem
initialize
in class AbstractLoggingSystem
initializationContext
- the logging initialization contextconfigLocation
- a log configuration location or null
if default
initialization is requiredlogFile
- the log output file that should be written or null
for
console only outputprotected void loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile)
AbstractLoggingSystem
loadDefaults
in class AbstractLoggingSystem
initializationContext
- the logging initialization contextlogFile
- the file to load or null
if no log file is to be writtenprotected void loadConfiguration(LoggingInitializationContext initializationContext, java.lang.String location, LogFile logFile)
AbstractLoggingSystem
loadConfiguration
in class Slf4JLoggingSystem
initializationContext
- the logging initialization contextlocation
- the location of the configuration to load (never null
)logFile
- the file to load or null
if no log file is to be written@Deprecated protected void loadConfiguration(java.lang.String location, LogFile logFile)
loadConfiguration(String, LogFile, List)
location
.location
- the locationlogFile
- log file configurationprotected void loadConfiguration(java.lang.String location, LogFile logFile, java.util.List<java.lang.String> overrides)
location
, creating a composite using
the configuration from the given overrides
.location
- the locationlogFile
- log file configurationoverrides
- the overriding locationsprotected void reinitialize(LoggingInitializationContext initializationContext)
AbstractLoggingSystem
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).reinitialize
in class AbstractLoggingSystem
initializationContext
- the logging initialization contextpublic java.util.Set<LogLevel> getSupportedLogLevels()
LoggingSystem
LogLevels
that are actually supported by the
logging system.getSupportedLogLevels
in class LoggingSystem
public void setLogLevel(java.lang.String loggerName, LogLevel logLevel)
LoggingSystem
setLogLevel
in class LoggingSystem
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)public java.util.List<LoggerConfiguration> getLoggerConfigurations()
LoggingSystem
LoggingSystem
's
loggers.getLoggerConfigurations
in class LoggingSystem
public LoggerConfiguration getLoggerConfiguration(java.lang.String loggerName)
LoggingSystem
LoggingSystem
's logger.getLoggerConfiguration
in class LoggingSystem
loggerName
- the name of the loggerpublic java.lang.Runnable getShutdownHandler()
LoggingSystem
Runnable
that can handle shutdown of this logging system when the
JVM exits. The default implementation returns null
, indicating that no
shutdown is required.getShutdownHandler
in class LoggingSystem
null
public void cleanUp()
LoggingSystem
cleanUp
in class Slf4JLoggingSystem