org.apache.logging.log4j.core.appender
Class OutputStreamManager

java.lang.Object
  extended by org.apache.logging.log4j.core.appender.AbstractManager
      extended by org.apache.logging.log4j.core.appender.OutputStreamManager
Direct Known Subclasses:
AbstractSocketManager, FileManager, MemoryMappedFileManager, RandomAccessFileManager

public class OutputStreamManager
extends AbstractManager

Manages an OutputStream so that it can be shared by multiple Appenders and will allow appenders to reconfigure without requiring a new stream.


Field Summary
protected  Layout<?> layout
           
 
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
 
Constructor Summary
protected OutputStreamManager(OutputStream os, String streamName, Layout<?> layout)
           
 
Method Summary
protected  void close()
           
 void flush()
          Flushes any buffers.
static
<T> OutputStreamManager
getManager(String name, T data, ManagerFactory<? extends OutputStreamManager,T> factory)
          Creates a Manager.
protected  OutputStream getOutputStream()
           
 boolean isOpen()
          Returns the status of the stream.
 void releaseSub()
          Default hook to write footer during close.
protected  void setOutputStream(OutputStream os)
           
protected  void write(byte[] bytes)
          Some output streams synchronize writes while others do not.
protected  void write(byte[] bytes, int offset, int length)
          Some output streams synchronize writes while others do not.
protected  void writeFooter()
          Writes the footer.
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
getContentFormat, getCount, getName, hasManager, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layout

protected final Layout<?> layout
Constructor Detail

OutputStreamManager

protected OutputStreamManager(OutputStream os,
                              String streamName,
                              Layout<?> layout)
Method Detail

getManager

public static <T> OutputStreamManager getManager(String name,
                                                 T data,
                                                 ManagerFactory<? extends OutputStreamManager,T> factory)
Creates a Manager.

Type Parameters:
T - The type of the OutputStreamManager.
Parameters:
name - The name of the stream to manage.
data - The data to pass to the Manager.
factory - The factory to use to create the Manager.
Returns:
An OutputStreamManager.

releaseSub

public void releaseSub()
Default hook to write footer during close.

Overrides:
releaseSub in class AbstractManager

writeFooter

protected void writeFooter()
Writes the footer.


isOpen

public boolean isOpen()
Returns the status of the stream.

Returns:
true if the stream is open, false if it is not.

getOutputStream

protected OutputStream getOutputStream()

setOutputStream

protected void setOutputStream(OutputStream os)

write

protected void write(byte[] bytes,
                     int offset,
                     int length)
Some output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.

Parameters:
bytes - The serialized Log event.
offset - The offset into the byte array.
length - The number of bytes to write.
Throws:
AppenderLoggingException - if an error occurs.

write

protected void write(byte[] bytes)
Some output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.

Parameters:
bytes - The serialized Log event.
Throws:
AppenderLoggingException - if an error occurs.

close

protected void close()

flush

public void flush()
Flushes any buffers.



Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.