Package org.swisspush.gateleen.logging
Class Log4jConfigurator
- java.lang.Object
-
- org.swisspush.gateleen.logging.Log4jConfigurator
-
public class Log4jConfigurator extends Object
Configurator used to configure a log4j repository dynamically. Wheter all known loggers or only the explicitly configured loggers are configured is defined by the system property "org.swisspush.gateleen.logging.log4j.showall" which defaults to false. Thus per default only the loggers are modified that have been explicitly configured to the log4j system (typically via a log4j configuration file such as log4j.properties).- Author:
- schwabmar
- See Also:
SYS_PROP_SHOW_ALL
-
-
Field Summary
Fields Modifier and Type Field Description static StringSYS_PROP_SHOW_ALLName of the "show all loggers" system property.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>getAppenders(String logger)Gets the appenders to a specific logger.org.apache.log4j.LevelgetEffectiveLevel(String logger)Gets a logger's effective level thus either the direct level or the inherited level from it's parent logger.static Log4jConfiguratorgetInstance()Gets the one-and-only instance of the classLog4jConfigurator.org.apache.log4j.LevelgetLevel(String logger)Gets a logger's actual level.List<String>getLoggers()Retrieves all loggers from the log4j repository.List<String>getLoggersSorted()Retrieves all loggers from the log4j repository.voidsetLoggerLevel(String logger, String level)Sets or deletes a logger's new level.
-
-
-
Field Detail
-
SYS_PROP_SHOW_ALL
public static final String SYS_PROP_SHOW_ALL
Name of the "show all loggers" system property.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static Log4jConfigurator getInstance()
Gets the one-and-only instance of the classLog4jConfigurator.- Returns:
- Instance.
-
getLoggers
public List<String> getLoggers()
Retrieves all loggers from the log4j repository. Dependent on the flag showAll, this method either returns only the direct configured loggers or all known loggers.- Returns:
- List of
java.lang.Stringcontaining all logger names. - See Also:
SYS_PROP_SHOW_ALL
-
getLoggersSorted
public List<String> getLoggersSorted()
Retrieves all loggers from the log4j repository. Dependent on the flag showAll, this method either returns only the direct configured loggers or all known loggers.- Returns:
- Sorted list of
java.lang.Stringcontaining all logger names. - See Also:
SYS_PROP_SHOW_ALL
-
getAppenders
public List<String> getAppenders(String logger) throws IllegalArgumentException
Gets the appenders to a specific logger.- Parameters:
logger- A logger's name.- Returns:
- List of
java.lang.Stringcontaining all appender names. - Throws:
IllegalArgumentException- In case the logger isn't known.
-
getLevel
public org.apache.log4j.Level getLevel(String logger) throws IllegalArgumentException
Gets a logger's actual level.- Parameters:
logger- The logger.- Returns:
- The logger's level or
nullif no level was directly set on the logger. - Throws:
IllegalArgumentException- In case the logger isn't known.
-
getEffectiveLevel
public org.apache.log4j.Level getEffectiveLevel(String logger) throws IllegalArgumentException
Gets a logger's effective level thus either the direct level or the inherited level from it's parent logger.- Parameters:
logger- The logger.- Returns:
- The logger's effective level.
- Throws:
IllegalArgumentException- In case the logger isn't known.
-
setLoggerLevel
public void setLoggerLevel(String logger, String level) throws IllegalArgumentException
Sets or deletes a logger's new level.- Parameters:
logger- Name of the logger to set.level- Level to set the logger to.- Throws:
IllegalArgumentException- In case the logger isn't known.
-
-