sg.edu.nus.logging
Class Logger

java.lang.Object
  extended by sg.edu.nus.logging.Logger

public final class Logger
extends java.lang.Object

A simple wrapper of java.util.logging.Logger.

Version:
1.0 2006-7-17
Author:
Xu Linhao

Constructor Summary
Logger(java.lang.String name)
          Create a new logger for a named subsystem.
 
Method Summary
 void addHandler(java.util.logging.FileHandler handler)
          Add a file handler to logger.
 void debug(java.lang.String message)
          Wrap the log method of the java.util.logging.Logger by setting the Level as FINER.
 void debug(java.lang.String message, java.lang.Throwable thrown)
          Wrap the log method of the java.util.logging.Logger by setting the Level as FINER.
 void enableDebug()
          Enable the logger to record the a fairly detailed tracing message.
 void error(java.lang.String message)
          Wrap the logp method of the java.util.logging.Logger by setting the Level as SEVERE.
 void error(java.lang.String message, java.lang.Throwable thrown)
          Wrap the log method of the java.util.logging.Logger by setting the Level as SEVERE.
static Logger getLogger(java.lang.String name)
          Find or create a logger for a named subsystem.
 void info(java.lang.String message)
          Wrap the log method of the java.util.logging.Logger by setting the Level as INFO.
 void info(java.lang.String message, java.lang.Throwable thrown)
          Wrap the log method of the java.util.logging.Logger by setting the Level as INFO.
 boolean isDebugEnabled()
          Judge if the logger enables the debug model.
 void warn(java.lang.String message)
          Wrap the log method of the java.util.logging.Logger by setting the Level as WARNING.
 void warn(java.lang.String message, java.lang.Throwable thrown)
          Wrap the log method of the java.util.logging.Logger by setting the Level as WARNING.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logger

public Logger(java.lang.String name)
Create a new logger for a named subsystem.

Parameters:
name - A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as java.net
Method Detail

getLogger

public static Logger getLogger(java.lang.String name)
Find or create a logger for a named subsystem. If a logger has already been created with the given name it is returned. Otherwise a new logger is created.

Parameters:
name - A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as java.net

addHandler

public void addHandler(java.util.logging.FileHandler handler)
Add a file handler to logger.

Parameters:
handler - the file handler

info

public void info(java.lang.String message)
Wrap the log method of the java.util.logging.Logger by setting the Level as INFO.

Parameters:
message - the string message (or a key in the message catalog)

info

public void info(java.lang.String message,
                 java.lang.Throwable thrown)
Wrap the log method of the java.util.logging.Logger by setting the Level as INFO.

Parameters:
message - the string message (or a key in the message catalog)
thrown - throwable associated with log message

debug

public void debug(java.lang.String message)
Wrap the log method of the java.util.logging.Logger by setting the Level as FINER.

Parameters:
message - the string message (or a key in the message catalog)

debug

public void debug(java.lang.String message,
                  java.lang.Throwable thrown)
Wrap the log method of the java.util.logging.Logger by setting the Level as FINER.

Parameters:
message - the string message (or a key in the message catalog)
thrown - throwable associated with log message

warn

public void warn(java.lang.String message)
Wrap the log method of the java.util.logging.Logger by setting the Level as WARNING.

Parameters:
message - the string message (or a key in the message catalog)

warn

public void warn(java.lang.String message,
                 java.lang.Throwable thrown)
Wrap the log method of the java.util.logging.Logger by setting the Level as WARNING.

Parameters:
message - the string message (or a key in the message catalog)
thrown - throwable associated with log message

error

public void error(java.lang.String message)
Wrap the logp method of the java.util.logging.Logger by setting the Level as SEVERE.

Parameters:
message - the string message (or a key in the message catalog)

error

public void error(java.lang.String message,
                  java.lang.Throwable thrown)
Wrap the log method of the java.util.logging.Logger by setting the Level as SEVERE.

Parameters:
message - the string message (or a key in the message catalog)
thrown - throwable associated with log message

isDebugEnabled

public boolean isDebugEnabled()
Judge if the logger enables the debug model.

Returns:
true if the debug model is enabled

enableDebug

public void enableDebug()
Enable the logger to record the a fairly detailed tracing message. By default logging calls for entering, returning, or throwing an exception are traced at this level.