org.mortbay.log
Class OutputStreamLogSink

java.lang.Object
  extended by org.mortbay.log.OutputStreamLogSink
All Implemented Interfaces:
java.io.Serializable, LogSink, LifeCycle

public class OutputStreamLogSink
extends java.lang.Object
implements LogSink

A Log sink. This class represents both a concrete or abstract sink of Log data. The default implementation logs to System.err, but other output stream or files may be specified. Currently this Stream only writes in ISO8859_1 encoding. For Other encodings use the less efficient WriterLogSink. If a logFilename is specified, output is sent to that file. If the filename contains "yyyy_mm_dd", the log file date format is used to create the actual filename and the log file is rolled over at local midnight. If append is set, existing logfiles are appended to, otherwise a backup is created with a timestamp. Dated log files are deleted after retain days.

If the property LOG_DATE_FORMAT is set, then it is interpreted as a format string for java.text.SimpleDateFormat and used to format the log timestamps. Default value: HH:mm:ss.SSS

If LOG_TIMEZONE is set, it is used to set the timezone of the log date format, otherwise GMT is used.

Version:
$Id: OutputStreamLogSink.java,v 1.4 2004/09/19 08:04:57 gregwilkins Exp $
Author:
Greg Wilkins (gregw)
See Also:
org.mortbay.util.Log, Serialized Form

Field Summary
protected  ByteArrayISO8859Writer _buffer
           
protected  int _bufferSize
           
protected  DateCache _dateFormat
           
protected  boolean _flushOn
           
protected  LogImpl _logImpl
           
protected  boolean _logLabels
           
protected  boolean _logOneLine
           
protected  boolean _logStackSize
           
protected  boolean _logStackTrace
           
protected  boolean _logTags
           
protected  boolean _logTimeStamps
           
protected  java.lang.String _logTimezone
           
protected  java.io.OutputStream _out
           
protected  boolean _reopen
           
protected  boolean _started
           
protected  boolean _suppressStack
           
 
Constructor Summary
OutputStreamLogSink()
          Constructor.
OutputStreamLogSink(java.lang.String filename)
           
 
Method Summary
 java.lang.String getDatedFilename()
           
 java.lang.String getFilename()
           
 boolean getFlushOn()
           
 java.lang.String getLogDateFormat()
           
 java.lang.String getLogTimezone()
          Deprecated. Use getLogTimeZone()
 java.lang.String getLogTimeZone()
           
 java.io.OutputStream getOutputStream()
           
 int getRetainDays()
           
 boolean isAppend()
           
 boolean isLogLabels()
           
 boolean isLogOneLine()
           
 boolean isLogStackSize()
           
 boolean isLogStackTrace()
           
 boolean isLogTags()
           
 boolean isLogTimeStamps()
           
 boolean isStarted()
           
 boolean isSuppressStack()
           
 void log(java.lang.String formattedLog)
          Log a message.
 void log(java.lang.String tag, java.lang.Object o, Frame frame, long time)
          Log a message.
 void setAppend(boolean a)
           
 void setFilename(java.lang.String filename)
           
 void setFlushOn(boolean on)
           
 void setLogDateFormat(java.lang.String logDateFormat)
           
 void setLogImpl(LogImpl impl)
           
 void setLogLabels(boolean logLabels)
           
 void setLogOneLine(boolean logOneLine)
           
 void setLogStackSize(boolean logStackSize)
           
 void setLogStackTrace(boolean logStackTrace)
           
 void setLogTags(boolean logTags)
           
 void setLogTimeStamps(boolean logTimeStamps)
           
 void setLogTimezone(java.lang.String logTimezone)
          Deprecated. Use setLogTimeZone(String)
 void setLogTimeZone(java.lang.String logTimezone)
           
 void setOutputStream(java.io.OutputStream out)
           
 void setRetainDays(int retainDays)
           
 void setSuppressStack(boolean suppressStack)
           
 void start()
          Start a log sink.
 void stop()
          Stop a log sink.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_dateFormat

protected DateCache _dateFormat

_logTimezone

protected java.lang.String _logTimezone

_logTimeStamps

protected boolean _logTimeStamps

_logLabels

protected boolean _logLabels

_logTags

protected boolean _logTags

_logStackSize

protected boolean _logStackSize

_logStackTrace

protected boolean _logStackTrace

_logOneLine

protected boolean _logOneLine

_suppressStack

protected boolean _suppressStack

_flushOn

protected boolean _flushOn

_bufferSize

protected int _bufferSize

_reopen

protected boolean _reopen

_logImpl

protected transient LogImpl _logImpl

_started

protected transient boolean _started

_out

protected transient java.io.OutputStream _out

_buffer

protected transient ByteArrayISO8859Writer _buffer
Constructor Detail

OutputStreamLogSink

public OutputStreamLogSink()
                    throws java.io.IOException
Constructor.

Throws:
java.io.IOException

OutputStreamLogSink

public OutputStreamLogSink(java.lang.String filename)
Method Detail

getLogDateFormat

public java.lang.String getLogDateFormat()

setLogDateFormat

public void setLogDateFormat(java.lang.String logDateFormat)

getLogTimezone

public java.lang.String getLogTimezone()
Deprecated. Use getLogTimeZone()


setLogTimezone

public void setLogTimezone(java.lang.String logTimezone)
Deprecated. Use setLogTimeZone(String)


getLogTimeZone

public java.lang.String getLogTimeZone()

setLogTimeZone

public void setLogTimeZone(java.lang.String logTimezone)

isLogTimeStamps

public boolean isLogTimeStamps()

setLogTimeStamps

public void setLogTimeStamps(boolean logTimeStamps)

isLogLabels

public boolean isLogLabels()

setLogLabels

public void setLogLabels(boolean logLabels)

isLogTags

public boolean isLogTags()

setLogTags

public void setLogTags(boolean logTags)

isLogStackSize

public boolean isLogStackSize()

setLogStackSize

public void setLogStackSize(boolean logStackSize)

isLogStackTrace

public boolean isLogStackTrace()

setLogStackTrace

public void setLogStackTrace(boolean logStackTrace)

isLogOneLine

public boolean isLogOneLine()

setLogOneLine

public void setLogOneLine(boolean logOneLine)

isAppend

public boolean isAppend()

setAppend

public void setAppend(boolean a)

isSuppressStack

public boolean isSuppressStack()

setSuppressStack

public void setSuppressStack(boolean suppressStack)

setOutputStream

public void setOutputStream(java.io.OutputStream out)

getOutputStream

public java.io.OutputStream getOutputStream()

setFilename

public void setFilename(java.lang.String filename)

getFilename

public java.lang.String getFilename()

getDatedFilename

public java.lang.String getDatedFilename()

getRetainDays

public int getRetainDays()

setRetainDays

public void setRetainDays(int retainDays)

setFlushOn

public void setFlushOn(boolean on)
Parameters:
on - If true, log is flushed on every log.

getFlushOn

public boolean getFlushOn()
Returns:
true, log is flushed on every log.

log

public void log(java.lang.String tag,
                java.lang.Object o,
                Frame frame,
                long time)
Log a message. This method formats the log information as a string and calls log(String). It should only be specialized by a derived implementation if the format of the logged messages is to be changed.

Specified by:
log in interface LogSink
Parameters:
tag - Tag for type of log
msg - The message
frame - The frame that generated the message.
time - The time stamp of the message.

log

public void log(java.lang.String formattedLog)
Log a message. The formatted log string is written to the log sink. The default implementation writes the message to an outputstream.

Specified by:
log in interface LogSink
Parameters:
formattedLog -

start

public void start()
Start a log sink. The default implementation does nothing

Specified by:
start in interface LifeCycle

stop

public void stop()
Stop a log sink. An opportunity for subclasses to clean up. The default implementation does nothing

Specified by:
stop in interface LifeCycle

isStarted

public boolean isStarted()
Specified by:
isStarted in interface LifeCycle
Returns:
True if the LifeCycle has been started.

setLogImpl

public void setLogImpl(LogImpl impl)
Specified by:
setLogImpl in interface LogSink


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.