Package org.apache.log.output.io
Class StreamTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.AbstractOutputTarget
org.apache.log.output.io.StreamTarget
- All Implemented Interfaces:
ErrorAware
,LogTarget
,Closeable
- Direct Known Subclasses:
FileTarget
A basic target that writes to an OutputStream.
- Author:
- Peter Donald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The encoding to use when creating byte array for string, may be null.private OutputStream
OutputStream we are writing to. -
Constructor Summary
ConstructorsConstructorDescriptionStreamTarget
(OutputStream outputStream, Formatter formatter) Constructor that writes to a stream and uses a particular formatter.StreamTarget
(OutputStream outputStream, Formatter formatter, String encoding) Constructor that writes to a stream and uses a particular formatter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Shutdown target.protected void
setOutputStream
(OutputStream outputStream) Set the output stream.protected void
Shutdown output stream.protected void
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
-
Field Details
-
m_outputStream
OutputStream we are writing to. -
m_encoding
The encoding to use when creating byte array for string, may be null.
-
-
Constructor Details
-
StreamTarget
Constructor that writes to a stream and uses a particular formatter.- Parameters:
outputStream
- the OutputStream to write toformatter
- the Formatter to useencoding
- Desired encoding to use when writing to the log, null implies the default system encoding.
-
StreamTarget
Constructor that writes to a stream and uses a particular formatter.- Parameters:
outputStream
- the OutputStream to write toformatter
- the Formatter to use
-
-
Method Details
-
setOutputStream
Set the output stream. Close down old stream and write tail if appropriate.- Parameters:
outputStream
- the new OutputStream
-
write
Abstract method that will output event.- Overrides:
write
in classAbstractOutputTarget
- 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 interfaceCloseable
- Overrides:
close
in classAbstractOutputTarget
-
shutdownStream
protected void shutdownStream()Shutdown output stream.
-