org.mortbay.util
Class Log

java.lang.Object
  |
  +--org.mortbay.util.Log

public class Log
extends java.lang.Object

Log formatted and tagged messages. Multiple LogSinks instances can be configured, but by default a System.err sink is created.

The Log log format is controlled by the LOG_OPTIONS property supplied to the VM.

If LOG_OPTIONS is set, then the default output format is controlled by the option characters in the string:

 t Timestamp log output
 T Show the log tag name
 L Show log label (thread, method and file names).
 s Show indication of stack depth
 S Stack trace for each output line (VERY VERBOSE)
 O Place each log one One line of output
 

If the property LOG_CLASSES is set, it is interpreted as a semi-colon-separated list of fully-qualified LogSink class names. An instance of each class, created with a default constructor, is added to the list of log sinks. Some possibilities for LOG_CLASSES are org.mortbay.util.OutputStreamLogSink - log to System.err, a file whose name is specified in LOG_FILE, and optionally rollover the logs on a daily basis. See the javadoc for org.mortbay.util.OutputStreamLogSink for information on the options LOG_DATE_FORMAT, LOG_FILE_BACKUP_FORMAT, LOG_FILE_RETAIN_DAYS, LOG_FILE_DATE_FORMAT and LOG_TIME_ZONE.

If the property LOG_CLASSES is missing, a single OutputStreamLogSink is used to output to System.err.

As an alternative to the above behavior, you can create LogSinks in code and add() them to the Log. If you do this before the first use of the log, the default initialization will be skipped.

See Also:
OutputStreamLogSink

Field Summary
 java.lang.String _logOptions
           
 LogSink[] _sinks
           
static java.lang.String ASSERT
           
static java.lang.String DEBUG
           
static java.lang.String EVENT
           
static java.lang.String FAIL
           
static java.lang.String WARN
           
 
Method Summary
 void add(LogSink logSink)
          Add a Log Sink.
 void add(java.lang.String logSinkClass)
          Add a Log Sink.
 void deleteStoppedLogSinks()
           
 void disableLog()
          No logging.
static void event(java.lang.Object message)
          Log an event.
static void event(java.lang.Object message, int stackDepth)
          Log an event.
 LogSink[] getLogSinks()
           
 java.lang.String getOptions()
           
static Log instance()
           
static void message(java.lang.String tag, java.lang.Object msg, Frame frame)
           
 void message(java.lang.String tag, java.lang.Object msg, Frame frame, long time)
          Log a message.
 void message(java.lang.String tag, java.lang.String msg)
          Log a message.
 void setOptions(java.lang.String logOptions)
           
static void warning(java.lang.Object message)
          Log a warning.
static void warning(java.lang.Object message, int stackDepth)
          Log a warning message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final java.lang.String DEBUG
See Also:
Constant Field Values

EVENT

public static final java.lang.String EVENT
See Also:
Constant Field Values

WARN

public static final java.lang.String WARN
See Also:
Constant Field Values

ASSERT

public static final java.lang.String ASSERT
See Also:
Constant Field Values

FAIL

public static final java.lang.String FAIL
See Also:
Constant Field Values

_sinks

public LogSink[] _sinks

_logOptions

public java.lang.String _logOptions
Method Detail

instance

public static Log instance()

add

public void add(java.lang.String logSinkClass)
Add a Log Sink.

Parameters:
logSinkClass - The logsink classname or null for the default.

add

public void add(LogSink logSink)
Add a Log Sink.

Parameters:
logSink -

getLogSinks

public LogSink[] getLogSinks()

deleteStoppedLogSinks

public void deleteStoppedLogSinks()

disableLog

public void disableLog()
No logging. All log sinks are stopped and removed.


message

public static void message(java.lang.String tag,
                           java.lang.Object msg,
                           Frame frame)

event

public static void event(java.lang.Object message,
                         int stackDepth)
Log an event.


event

public static void event(java.lang.Object message)
Log an event.


warning

public static void warning(java.lang.Object message,
                           int stackDepth)
Log a warning message.

Parameters:
message - the Object to use as a warning message.
stackDepth - number of levels of stack to ignore.
See Also:
for warnings of exceptions etc.

warning

public static void warning(java.lang.Object message)
Log a warning.

Parameters:
message - the Object to use as a warning message.
See Also:
for warnings of exceptions etc.

message

public void message(java.lang.String tag,
                    java.lang.Object msg,
                    Frame frame,
                    long time)
Log a message.

Parameters:
tag - Tag for type of log
msg - The message
frame - The frame that generated the message.
time - The time stamp of the message.

message

public void message(java.lang.String tag,
                    java.lang.String msg)
Log a message.

Parameters:
tag - Tag for type of log
msg - The message

setOptions

public void setOptions(java.lang.String logOptions)

getOptions

public java.lang.String getOptions()


Copyright ? 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.