FileDocCategorySizeDatePackage
Logger.javaAPI DocApache log4j 1.2.156800Sat Aug 25 00:09:42 BST 2007org.apache.log4j

Logger

public class Logger extends Category
This is the central class in the log4j package. Most logging operations, except configuration, are done through this class.
since
log4j 1.2
author
Ceki Gülcü

Fields Summary
private static final String
FQCN
The fully qualified name of the Logger class. See also the getFQCN method.
Constructors Summary
protected Logger(String name)



  
    
    super(name);
  
Methods Summary
public static org.apache.log4j.LoggergetLogger(java.lang.String name)
Retrieve a logger named according to the value of the name parameter. If the named logger already exists, then the existing instance will be returned. Otherwise, a new instance is created.

By default, loggers do not have a set level but inherit it from their neareast ancestor with a set level. This is one of the central features of log4j.

param
name The name of the logger to retrieve.

    return LogManager.getLogger(name);
  
public static org.apache.log4j.LoggergetLogger(java.lang.Class clazz)
Shorthand for getLogger(clazz.getName()).

param
clazz The name of clazz will be used as the name of the logger to retrieve. See {@link #getLogger(String)} for more detailed information.

    return LogManager.getLogger(clazz.getName());
  
public static org.apache.log4j.LoggergetLogger(java.lang.String name, org.apache.log4j.spi.LoggerFactory factory)
Like {@link #getLogger(String)} except that the type of logger instantiated depends on the type returned by the {@link LoggerFactory#makeNewLoggerInstance} method of the factory parameter.

This method is intended to be used by sub-classes.

param
name The name of the logger to retrieve.
param
factory A {@link LoggerFactory} implementation that will actually create a new Instance.
since
0.8.5

    return LogManager.getLogger(name, factory);
  
public static org.apache.log4j.LoggergetRootLogger()
Return the root logger for the current logger repository.

The {@link #getName Logger.getName()} method for the root logger always returns stirng value: "root". However, calling Logger.getLogger("root") does not retrieve the root logger but a logger just under root named "root".

In other words, calling this method is the only way to retrieve the root logger.

    return LogManager.getRootLogger();
  
public booleanisTraceEnabled()
Check whether this category is enabled for the TRACE Level.

since
1.2.12
return
boolean - true if this category is enabled for level TRACE, false otherwise.

        if (repository.isDisabled(Level.TRACE_INT)) {
            return false;
          }

          return Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel());
    
public voidtrace(java.lang.Object message)
Log a message object with the {@link org.apache.log4j.Level#TRACE TRACE} level.

param
message the message object to log.
see
#debug(Object) for an explanation of the logic applied.
since
1.2.12

      if (repository.isDisabled(Level.TRACE_INT)) {
        return;
      }

      if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
        forcedLog(FQCN, Level.TRACE, message, null);
      }
    
public voidtrace(java.lang.Object message, java.lang.Throwable t)
Log a message object with the TRACE level including the stack trace of the {@link Throwable}t passed as parameter.

See {@link #debug(Object)} form for more detailed information.

param
message the message object to log.
param
t the exception to log, including its stack trace.
since
1.2.12

      if (repository.isDisabled(Level.TRACE_INT)) {
        return;
      }

      if (Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel())) {
        forcedLog(FQCN, Level.TRACE, message, t);
      }