Top Description Fields Constructors Methods
ch.qos.logback.core

public Class OutputStreamAppender<E>

extends UnsynchronizedAppenderBase<E>
Class Inheritance
Known Direct Subclasses
ch.qos.logback.core.ConsoleAppender, ch.qos.logback.core.FileAppender
Static Imports
ch.qos.logback.core.CoreConstants.CODES_URL

OutputStreamAppender appends events to a OutputStream. This class provides basic services that other appenders build upon. For more information about this appender, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#OutputStreamAppender
Author
Ceki Gülcü

Field Summary

Modifier and TypeField and Description
protected Encoder<E>
encoder

It is the encoder which is ultimately responsible for writing the event to an OutputStream.

pack-priv boolean
private OutputStream
outputStream

This is the outputStream where output will be written.

protected final ReentrantLock
streamWriteLock

All synchronization in this class is done via the lock object.

Inherited from ch.qos.logback.core.UnsynchronizedAppenderBase:
ALLOWED_REPEATSnamestarted

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
closeOutputStream()

Close the underlying OutputStream.

pack-priv void
pack-priv void
public Encoder<E>
public OutputStream
getOutputStream()

The underlying output stream used by this appender.

public boolean
public void
setEncoder(Encoder<E> encoder)

public void
setImmediateFlush(boolean immediateFlush)

public void
setLayout(Layout<E> layout)

public void
setOutputStream(OutputStream
An already opened OutputStream.
outputStream
)

Sets the @link OutputStream} where the log output will go.

public void
start()

Overrides ch.qos.logback.core.UnsynchronizedAppenderBase.start.

Implements ch.qos.logback.core.spi.LifeCycle.start.

Checks that requires parameters are set and if everything is in order, activates this appender.
public void
protected void
subAppend(E event)

Actual writing occurs here.

protected final void
writeByteArrayToOutputStreamWithPossibleFlush(byte[] byteArray)

A simple method to write to an outputStream and flush the stream if immediateFlush is set to true.

private void
writeBytes(byte[] byteArray)

protected void
writeOut(E event)

Inherited from ch.qos.logback.core.UnsynchronizedAppenderBase:
addFilterclearAllFiltersdoAppendgetCopyOfAttachedFiltersListgetFilterChainDecisiongetNameisStartedsetNametoString

Field Detail

encoderback to summary
protected Encoder<E> encoder

It is the encoder which is ultimately responsible for writing the event to an OutputStream.

immediateFlushback to summary
pack-priv boolean immediateFlush
outputStreamback to summary
private OutputStream outputStream

This is the outputStream where output will be written.

streamWriteLockback to summary
protected final ReentrantLock streamWriteLock

All synchronization in this class is done via the lock object.

Constructor Detail

OutputStreamAppenderback to summary
public OutputStreamAppender()

Method Detail

appendback to summary
protected void append(E eventObject)

Implements abstract ch.qos.logback.core.UnsynchronizedAppenderBase.append.

Annotations
@Override
closeOutputStreamback to summary
protected void closeOutputStream()

Close the underlying OutputStream.

encoderCloseback to summary
pack-priv void encoderClose()
encoderInitback to summary
pack-priv void encoderInit()
getEncoderback to summary
public Encoder<E> getEncoder()
getOutputStreamback to summary
public OutputStream getOutputStream()

The underlying output stream used by this appender.

isImmediateFlushback to summary
public boolean isImmediateFlush()
setEncoderback to summary
public void setEncoder(Encoder<E> encoder)
setImmediateFlushback to summary
public void setImmediateFlush(boolean immediateFlush)
setLayoutback to summary
public void setLayout(Layout<E> layout)
setOutputStreamback to summary
public void setOutputStream(OutputStream outputStream)

Sets the @link OutputStream} where the log output will go. The specified OutputStream must be opened by the user and be writable. The OutputStream will be closed when the appender instance is closed.

Parameters
outputStream:OutputStream

An already opened OutputStream.

startback to summary
public void start()

Overrides ch.qos.logback.core.UnsynchronizedAppenderBase.start.

Implements ch.qos.logback.core.spi.LifeCycle.start.

Checks that requires parameters are set and if everything is in order, activates this appender.

stopback to summary
public void stop()

Overrides ch.qos.logback.core.UnsynchronizedAppenderBase.stop.

Implements ch.qos.logback.core.spi.LifeCycle.stop.

Stop this appender instance. The underlying stream or writer is also closed.

Stopped appenders cannot be reused.

subAppendback to summary
protected void subAppend(E event)

Actual writing occurs here.

Most subclasses of WriterAppender will need to override this method.

Since
0.9.0
writeByteArrayToOutputStreamWithPossibleFlushback to summary
protected final void writeByteArrayToOutputStreamWithPossibleFlush(byte[] byteArray) throws IOException

A simple method to write to an outputStream and flush the stream if immediateFlush is set to true.

Since
1.3.9/1.4.9
writeBytesback to summary
private void writeBytes(byte[] byteArray) throws IOException
writeOutback to summary
protected void writeOut(E event) throws IOException