Log4j 1.2.6

org.apache.log4j
Class LogManager

java.lang.Object
  |
  +--org.apache.log4j.LogManager

public class LogManager
extends Object

Use the LogManager to retreive instances of Logger.

Author:
Ceki Gülcü

Field Summary
static String CONFIGURATOR_CLASS_KEY
          This string constant is set to log4j.configuratorClass.
static String DEFAULT_CONFIGURATION_FILE
          This string constant is set to log4j.properties the name of the file that will be searched by default in classpath.
static String DEFAULT_CONFIGURATION_KEY
          This string constant is set to log4j.configuration.
static String DEFAULT_INIT_OVERRIDE_KEY
          Setting the system property log4j.defaultInitOverride to "true" or any other value than "false" will skip default configuration process.
 
Constructor Summary
LogManager()
           
 
Method Summary
static Logger exists(String name)
           
static Enumeration getCurrentLoggers()
           
static Logger getLogger(Class clazz)
          Retrieve the appropriate Logger instance.
static Logger getLogger(String name)
          Retrieve the appropriate Logger instance.
static Logger getLogger(String name, LoggerFactory factory)
          Retrieve the appropriate Logger instance.
static LoggerRepository getLoggerRepository()
           
static Logger getRootLogger()
          Retrieve the appropriate root logger.
static void resetConfiguration()
           
static void setRepositorySelector(RepositorySelector selector, Object guard)
          Sets LoggerFactory but only if the correct guard is passed as parameter.
static void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONFIGURATION_FILE

public static final String DEFAULT_CONFIGURATION_FILE
This string constant is set to log4j.properties the name of the file that will be searched by default in classpath. If the file can be found, then it is fed to the PropertyConfigurator. See also DEFAULT_CONFIGURATION_KEY for a more general alternative.

See also the full description of default intialization procedure.

Since:
0.8.5

DEFAULT_CONFIGURATION_KEY

public static final String DEFAULT_CONFIGURATION_KEY
This string constant is set to log4j.configuration.

It corresponds to name of a system property that, if set, specifies the name of the resource containing the properties file or URL with which log4j should configure itself. See OptionConverter.selectAndConfigure(java.net.URL, java.lang.String, org.apache.log4j.spi.LoggerRepository) for more detailed information on the processing of this option.

Setting the log4j.configuration system property overrides the default search for the file log4j.properties.

Note that all property keys are case sensitive.

See also the full description of default intialization procedure.

Since:
1.0

CONFIGURATOR_CLASS_KEY

public static final String CONFIGURATOR_CLASS_KEY
This string constant is set to log4j.configuratorClass.

It corresponds to name of a system property that, if set, specifies the class name to use to automatically configure log4j. See OptionConverter.selectAndConfigure(java.net.URL, java.lang.String, org.apache.log4j.spi.LoggerRepository) for more detailed information on the processing of this option.

Setting the log4j.configuration system property overrides the default search for the file log4j.properties.

Note that all property keys are case sensitive.

See also the full description of default intialization procedure.

Since:
1.2

DEFAULT_INIT_OVERRIDE_KEY

public static final String DEFAULT_INIT_OVERRIDE_KEY
Setting the system property log4j.defaultInitOverride to "true" or any other value than "false" will skip default configuration process.

The current value of the DEFAULT_INIT_OVERRIDE_KEY string constant is log4j.defaultInitOverride.

See also the full description of default intialization procedure.

Note that all property keys are case sensitive.

Since:
0.8.5
Constructor Detail

LogManager

public LogManager()
Method Detail

setRepositorySelector

public static void setRepositorySelector(RepositorySelector selector,
                                         Object guard)
                                  throws IllegalArgumentException
Sets LoggerFactory 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 a IllegalArgumentException, unless the previously set guard is passed as the second parameter.

This allows a high-level component to set the RepositorySelector used by the LogManager.

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.


getLoggerRepository

public static LoggerRepository getLoggerRepository()

getRootLogger

public static Logger getRootLogger()
Retrieve the appropriate root logger.

getLogger

public static Logger getLogger(String name)
Retrieve the appropriate Logger instance.

getLogger

public static Logger getLogger(Class clazz)
Retrieve the appropriate Logger instance.

getLogger

public static Logger getLogger(String name,
                               LoggerFactory factory)
Retrieve the appropriate Logger instance.

exists

public static Logger exists(String name)

getCurrentLoggers

public static Enumeration getCurrentLoggers()

shutdown

public static void shutdown()

resetConfiguration

public static void resetConfiguration()

Log4j 1.2.6

Copyright 2000-2002 Apache Software Foundation.