org.mortbay.log

Class OutputStreamLogSink

public class OutputStreamLogSink extends 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

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 String_logTimezone
protected OutputStream_out
protected boolean_reopen
protected boolean_started
protected boolean_suppressStack
Constructor Summary
OutputStreamLogSink()
Constructor.
OutputStreamLogSink(String filename)
Method Summary
StringgetDatedFilename()
StringgetFilename()
booleangetFlushOn()
StringgetLogDateFormat()
StringgetLogTimezone()
StringgetLogTimeZone()
OutputStreamgetOutputStream()
intgetRetainDays()
booleanisAppend()
booleanisLogLabels()
booleanisLogOneLine()
booleanisLogStackSize()
booleanisLogStackTrace()
booleanisLogTags()
booleanisLogTimeStamps()
booleanisStarted()
booleanisSuppressStack()
voidlog(String tag, Object o, Frame frame, long time)
Log a message.
voidlog(String formattedLog)
Log a message.
voidsetAppend(boolean a)
voidsetFilename(String filename)
voidsetFlushOn(boolean on)
voidsetLogDateFormat(String logDateFormat)
voidsetLogImpl(LogImpl impl)
voidsetLogLabels(boolean logLabels)
voidsetLogOneLine(boolean logOneLine)
voidsetLogStackSize(boolean logStackSize)
voidsetLogStackTrace(boolean logStackTrace)
voidsetLogTags(boolean logTags)
voidsetLogTimeStamps(boolean logTimeStamps)
voidsetLogTimezone(String logTimezone)
voidsetLogTimeZone(String logTimezone)
voidsetOutputStream(OutputStream out)
voidsetRetainDays(int retainDays)
voidsetSuppressStack(boolean suppressStack)
voidstart()
Start a log sink.
voidstop()
Stop a log sink.

Field Detail

_buffer

protected transient ByteArrayISO8859Writer _buffer

_bufferSize

protected int _bufferSize

_dateFormat

protected DateCache _dateFormat

_flushOn

protected boolean _flushOn

_logImpl

protected transient LogImpl _logImpl

_logLabels

protected boolean _logLabels

_logOneLine

protected boolean _logOneLine

_logStackSize

protected boolean _logStackSize

_logStackTrace

protected boolean _logStackTrace

_logTags

protected boolean _logTags

_logTimeStamps

protected boolean _logTimeStamps

_logTimezone

protected String _logTimezone

_out

protected transient OutputStream _out

_reopen

protected boolean _reopen

_started

protected transient boolean _started

_suppressStack

protected boolean _suppressStack

Constructor Detail

OutputStreamLogSink

public OutputStreamLogSink()
Constructor.

OutputStreamLogSink

public OutputStreamLogSink(String filename)

Method Detail

getDatedFilename

public String getDatedFilename()

getFilename

public String getFilename()

getFlushOn

public boolean getFlushOn()

Returns: true, log is flushed on every log.

getLogDateFormat

public String getLogDateFormat()

getLogTimezone

public String getLogTimezone()

Deprecated: Use getLogTimeZone()

getLogTimeZone

public String getLogTimeZone()

getOutputStream

public OutputStream getOutputStream()

getRetainDays

public int getRetainDays()

isAppend

public boolean isAppend()

isLogLabels

public boolean isLogLabels()

isLogOneLine

public boolean isLogOneLine()

isLogStackSize

public boolean isLogStackSize()

isLogStackTrace

public boolean isLogStackTrace()

isLogTags

public boolean isLogTags()

isLogTimeStamps

public boolean isLogTimeStamps()

isStarted

public boolean isStarted()

isSuppressStack

public boolean isSuppressStack()

log

public void log(String tag, 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.

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(String formattedLog)
Log a message. The formatted log string is written to the log sink. The default implementation writes the message to an outputstream.

Parameters: formattedLog

setAppend

public void setAppend(boolean a)

setFilename

public void setFilename(String filename)

setFlushOn

public void setFlushOn(boolean on)

Parameters: on If true, log is flushed on every log.

setLogDateFormat

public void setLogDateFormat(String logDateFormat)

setLogImpl

public void setLogImpl(LogImpl impl)

setLogLabels

public void setLogLabels(boolean logLabels)

setLogOneLine

public void setLogOneLine(boolean logOneLine)

setLogStackSize

public void setLogStackSize(boolean logStackSize)

setLogStackTrace

public void setLogStackTrace(boolean logStackTrace)

setLogTags

public void setLogTags(boolean logTags)

setLogTimeStamps

public void setLogTimeStamps(boolean logTimeStamps)

setLogTimezone

public void setLogTimezone(String logTimezone)

Deprecated: Use setLogTimeZone(String)

setLogTimeZone

public void setLogTimeZone(String logTimezone)

setOutputStream

public void setOutputStream(OutputStream out)

setRetainDays

public void setRetainDays(int retainDays)

setSuppressStack

public void setSuppressStack(boolean suppressStack)

start

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

stop

public void stop()
Stop a log sink. An opportunity for subclasses to clean up. The default implementation does nothing
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.