com.niggle.util
Class Logger

java.lang.Object
  |
  +--com.niggle.util.Logger

public class Logger
extends java.lang.Object

A class that manages logging. Everything is setup and works through static methods.

Nothing needs to be done to use the logging system. In that case, errors are logged to stderr. By default, all log messages are logged.

A log file can be specified (setLogFileName()) and a log level can be set (setLogLevel()) in order to filter out less important messages. Log levels, in increasing order of severity are: LOG_DEBUG, LOG_INFO, LOG_WARN, and LOG_ERROR. LOG_ERROR cannot be filtered out.

The logging system can be setup from anywhere in a program, but it usually done from within init() or main().

In the end an implementor of Log is actually used to perform the logging. Any implementor of Log can be used.

I don't like this logging class much. It has no notion of the Servlet or ServletContext from which you are logging.(JR)


Field Summary
static int LOG_ALL
          Log level.
static int LOG_DEBUG
          Log level.
static int LOG_ERROR
          Log level.
static int LOG_INFO
          Log level.
static int LOG_WARN
          Log level.
 
Constructor Summary
Logger()
           
 
Method Summary
static Log getLog()
          Get the value of log.
static void log(java.lang.String msg)
          Log the message.
static void log(java.lang.String msg, int level)
          Log the message at the specified level.
static void logException(java.lang.Throwable t)
           
static void logException(java.lang.Throwable t, int level)
          log an exception, including the stack trace.
static void setLog(Log v)
          Set the value of log.
static void setLogFileName(java.lang.String newFile)
          Set the log file name.
static void setLogFileName(java.lang.String filename, boolean echoToCons)
          Set the log file name.
static void setLogLevel(int newLevel)
          Set the log level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_ALL

public static final int LOG_ALL
Log level.

LOG_DEBUG

public static final int LOG_DEBUG
Log level.

LOG_INFO

public static final int LOG_INFO
Log level.

LOG_WARN

public static final int LOG_WARN
Log level.

LOG_ERROR

public static final int LOG_ERROR
Log level.
Constructor Detail

Logger

public Logger()
Method Detail

setLogFileName

public static void setLogFileName(java.lang.String newFile)
Set the log file name.
Parameters:
newFile - the name of the log file to be used, which can be changed at any time. Note that, by default, log messages will also to stderr.

setLogFileName

public static void setLogFileName(java.lang.String filename,
                                  boolean echoToCons)
Set the log file name.
Parameters:
newFile - the name of the log file to be used, which can be changed at any time.
echoToCons - indicates whether to echo log messages to stderr as well.

getLog

public static Log getLog()
Get the value of log.
Returns:
Value of log.

setLog

public static void setLog(Log v)
Set the value of log.
Parameters:
v - Value to assign to log.

setLogLevel

public static void setLogLevel(int newLevel)
Set the log level.
Parameters:
newLevel - the lowest level for which messages should be logged.
require: (newLevel == LOG_ALL) || (newLevel == LOG_DEBUG) || (newLevel == LOG_INFO) || (newLevel == LOG_WARN) || (newLevel == LOG_ERROR)

log

public static void log(java.lang.String msg)
Log the message.
Parameters:
msg - the message to log.

log

public static void log(java.lang.String msg,
                       int level)
Log the message at the specified level.
Parameters:
msg - the message to log.
level - the level at which to log the message.
require: (newLevel == LOG_DEBUG) || (newLevel == LOG_INFO) || (newLevel == LOG_WARN) || (newLevel == LOG_ERROR)

logException

public static void logException(java.lang.Throwable t,
                                int level)
log an exception, including the stack trace. Also takes into account some exceptions that "tunnel" other exceptions, such as AssertionFailedException and org.xml.sax.SAXException

logException

public static void logException(java.lang.Throwable t)