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

public class OutputStreamManager
extends AbstractManager

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


Field Summary
 
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
 
Constructor Summary
protected OutputStreamManager(OutputStream os, String streamName)
           
 
Method Summary
protected  void close()
           
 void flush()
          Flush any buffers.
static OutputStreamManager getManager(String name, Object data, ManagerFactory<OutputStreamManager,Object> factory)
          Create a Manager.
protected  OutputStream getOutputStream()
           
 boolean isOpen()
          Return the status of the stream.
 void releaseSub()
          Default hook to write footer during close.
 void setFooter(byte[] footer)
          Set the footer to write when the stream is closed.
 void setHeader(byte[] header)
          Set the header to write when the stream is opened.
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.
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
getCount, getManager, getName, hasManager, release
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputStreamManager

protected OutputStreamManager(OutputStream os,
                              String streamName)
Method Detail

getManager

public static OutputStreamManager getManager(String name,
                                             Object data,
                                             ManagerFactory<OutputStreamManager,Object> factory)
Create a Manager.

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.

setHeader

public void setHeader(byte[] header)
Set the header to write when the stream is opened.

Parameters:
header - The header.

setFooter

public void setFooter(byte[] footer)
Set the footer to write when the stream is closed.

Parameters:
footer - The footer.

releaseSub

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

Overrides:
releaseSub in class AbstractManager

isOpen

public boolean isOpen()
Return 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:
AppenderRuntimeException - 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:
AppenderRuntimeException - if an error occurs.

close

protected void close()

flush

public void flush()
Flush any buffers.



Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.