org.apache.log.output.io
Class StreamTarget

java.lang.Object
  extended byorg.apache.log.output.AbstractTarget
      extended byorg.apache.log.output.AbstractOutputTarget
          extended byorg.apache.log.output.io.StreamTarget
All Implemented Interfaces:
Closeable, ErrorAware, LogTarget
Direct Known Subclasses:
FileTarget

public class StreamTarget
extends AbstractOutputTarget

A basic target that writes to an OutputStream.

Author:
Peter Donald

Constructor Summary
StreamTarget(java.io.OutputStream outputStream, Formatter formatter)
          Constructor that writes to a stream and uses a particular formatter.
StreamTarget(java.io.OutputStream outputStream, Formatter formatter, java.lang.String encoding)
          Constructor that writes to a stream and uses a particular formatter.
 
Method Summary
 void close()
          Shutdown target.
protected  void setOutputStream(java.io.OutputStream outputStream)
          Set the output stream.
protected  void shutdownStream()
          Shutdown output stream.
protected  void write(java.lang.String data)
          Abstract method that will output event.
 
Methods inherited from class org.apache.log.output.AbstractOutputTarget
doProcessEvent, getFormatter, open
 
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamTarget

public StreamTarget(java.io.OutputStream outputStream,
                    Formatter formatter,
                    java.lang.String encoding)
Constructor that writes to a stream and uses a particular formatter.

Parameters:
outputStream - the OutputStream to write to
formatter - the Formatter to use
encoding - Desired encoding to use when writing to the log, null implies the default system encoding.

StreamTarget

public StreamTarget(java.io.OutputStream outputStream,
                    Formatter formatter)
Constructor that writes to a stream and uses a particular formatter.

Parameters:
outputStream - the OutputStream to write to
formatter - the Formatter to use
Method Detail

setOutputStream

protected void setOutputStream(java.io.OutputStream outputStream)
Set the output stream. Close down old stream and write tail if appropriate.

Parameters:
outputStream - the new OutputStream

write

protected void write(java.lang.String data)
Abstract method that will output event.

Overrides:
write in class AbstractOutputTarget
Parameters:
data - the data to be output

close

public void close()
Shutdown target. Attempting to write to target after close() will cause errors to be logged.

Specified by:
close in interface Closeable
Overrides:
close in class AbstractOutputTarget

shutdownStream

protected void shutdownStream()
Shutdown output stream.



Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.