org.oreodata.util
Class Logger

java.lang.Object
  |
  +--org.oreodata.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 java.lang.String LINE_SEPARATOR
           
static int LOG_ALL
           
static int LOG_DEBUG
           
static int LOG_ERROR
           
static int LOG_INFO
           
static int LOG_WARN
           
 
Constructor Summary
Logger()
           
 
Method Summary
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 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.
static void setServletContext(javax.servlet.ServletContext servletContext)
           
 
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
See Also:
Constant Field Values

LOG_DEBUG

public static final int LOG_DEBUG
See Also:
Constant Field Values

LOG_INFO

public static final int LOG_INFO
See Also:
Constant Field Values

LOG_WARN

public static final int LOG_WARN
See Also:
Constant Field Values

LOG_ERROR

public static final int LOG_ERROR
See Also:
Constant Field Values

LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR
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.

setServletContext

public static void setServletContext(javax.servlet.ServletContext servletContext)

setLogFileName

public static void setLogFileName(java.lang.String filename,
                                  boolean echoToCons)
Set the log file name.

Parameters:
echoToCons - indicates whether to echo log messages to stderr as well.

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. should be one of:
  • Logger.LOG_DEBUG
  • Logger.LOG_INFO
  • Logger.LOG_WARN
  • Logger.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)