Package org.apache.log4j
Class LogManager
- java.lang.Object
-
- org.apache.log4j.LogManager
-
public class LogManager extends java.lang.Object
Use theLogManager
class to retreiveLogger
instances or to operate on the currentLoggerRepository
. When theLogManager
class is loaded into memory the default initalzation procedure is inititated. The default intialization procedure is described in the short log4j manual.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONFIGURATOR_CLASS_KEY
Deprecated.This variable is for internal use only.static java.lang.String
DEFAULT_CONFIGURATION_FILE
Deprecated.This variable is for internal use only.static java.lang.String
DEFAULT_CONFIGURATION_KEY
Deprecated.This variable is for internal use only.static java.lang.String
DEFAULT_INIT_OVERRIDE_KEY
Deprecated.This variable is for internal use only.(package private) static java.lang.String
DEFAULT_XML_CONFIGURATION_FILE
private static java.lang.Object
guard
private static RepositorySelector
repositorySelector
-
Constructor Summary
Constructors Constructor Description LogManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Logger
exists(java.lang.String name)
static java.util.Enumeration
getCurrentLoggers()
static Logger
getLogger(java.lang.Class clazz)
Retrieve the appropriateLogger
instance.static Logger
getLogger(java.lang.String name)
Retrieve the appropriateLogger
instance.static Logger
getLogger(java.lang.String name, LoggerFactory factory)
Retrieve the appropriateLogger
instance.static LoggerRepository
getLoggerRepository()
static Logger
getRootLogger()
Retrieve the appropriate root logger.private static boolean
isLikelySafeScenario(java.lang.Exception ex)
This method tests if called from a method that is known to result in class members being abnormally set to null but is assumed to be harmless since the all classes are in the process of being unloaded.static void
resetConfiguration()
static void
setRepositorySelector(RepositorySelector selector, java.lang.Object guard)
SetsLoggerFactory
but only if the correct guard is passed as parameter.static void
shutdown()
-
-
-
Field Detail
-
DEFAULT_CONFIGURATION_FILE
public static final java.lang.String DEFAULT_CONFIGURATION_FILE
Deprecated.This variable is for internal use only. It will become package protected in future versions.- See Also:
- Constant Field Values
-
DEFAULT_XML_CONFIGURATION_FILE
static final java.lang.String DEFAULT_XML_CONFIGURATION_FILE
- See Also:
- Constant Field Values
-
DEFAULT_CONFIGURATION_KEY
public static final java.lang.String DEFAULT_CONFIGURATION_KEY
Deprecated.This variable is for internal use only. It will become private in future versions.- See Also:
- Constant Field Values
-
CONFIGURATOR_CLASS_KEY
public static final java.lang.String CONFIGURATOR_CLASS_KEY
Deprecated.This variable is for internal use only. It will become private in future versions.- See Also:
- Constant Field Values
-
DEFAULT_INIT_OVERRIDE_KEY
public static final java.lang.String DEFAULT_INIT_OVERRIDE_KEY
Deprecated.This variable is for internal use only. It will become private in future versions.- See Also:
- Constant Field Values
-
guard
private static java.lang.Object guard
-
repositorySelector
private static RepositorySelector repositorySelector
-
-
Method Detail
-
setRepositorySelector
public static void setRepositorySelector(RepositorySelector selector, java.lang.Object guard) throws java.lang.IllegalArgumentException
SetsLoggerFactory
but only if the correct guard is passed as parameter.Initally the guard is null. If the guard is
null
, then invoking this method sets the logger factory and the guard. Following invocations will throw aIllegalArgumentException
, unless the previously setguard
is passed as the second parameter.This allows a high-level component to set the
RepositorySelector
used by theLogManager
.For example, when tomcat starts it will be able to install its own repository selector. However, if and when Tomcat is embedded within JBoss, then JBoss will install its own repository selector and Tomcat will use the repository selector set by its container, JBoss.
- Throws:
java.lang.IllegalArgumentException
-
isLikelySafeScenario
private static boolean isLikelySafeScenario(java.lang.Exception ex)
This method tests if called from a method that is known to result in class members being abnormally set to null but is assumed to be harmless since the all classes are in the process of being unloaded.- Parameters:
ex
- exception used to determine calling stack.- Returns:
- true if calling stack is recognized as likely safe.
-
getLoggerRepository
public static LoggerRepository getLoggerRepository()
-
getRootLogger
public static Logger getRootLogger()
Retrieve the appropriate root logger.
-
getLogger
public static Logger getLogger(java.lang.String name)
Retrieve the appropriateLogger
instance.
-
getLogger
public static Logger getLogger(java.lang.Class clazz)
Retrieve the appropriateLogger
instance.
-
getLogger
public static Logger getLogger(java.lang.String name, LoggerFactory factory)
Retrieve the appropriateLogger
instance.
-
exists
public static Logger exists(java.lang.String name)
-
getCurrentLoggers
public static java.util.Enumeration getCurrentLoggers()
-
shutdown
public static void shutdown()
-
resetConfiguration
public static void resetConfiguration()
-
-