de.fhg.igd.logging.log4j
Class AsynchronousWriterAppender

java.lang.Object
  extended byorg.apache.log4j.AppenderSkeleton
      extended byorg.apache.log4j.WriterAppender
          extended byde.fhg.igd.logging.log4j.AsynchronousWriterAppender
All Implemented Interfaces:
org.apache.log4j.Appender, Messenger, org.apache.log4j.spi.OptionHandler

public class AsynchronousWriterAppender
extends org.apache.log4j.WriterAppender
implements Messenger

This Appender is intended to be used for logging across slow or instable network connections. Because of the contained AbstractAsynchronousMessageDispatcher implementation append(org.apache.log4j.spi.LoggingEvent) will always return immediately, to make sure the delay of the main thread caused by the logging mechanism is minimized even under unfavorable network conditions.

Version:
"$Id: AsynchronousWriterAppender.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Nested Class Summary
private static class AsynchronousWriterAppender.Log4jMessageDispatcher
          This is the dispatcher implementation for the Log4J logging mechanism.
 
Field Summary
private  boolean closed_
          This flag will be set to true once close() has been called
private  AbstractAsynchronousMessageDispatcher dispatcher_
          The Asynchronous Message Dispatcher thread
 
Fields inherited from class org.apache.log4j.WriterAppender
encoding, immediateFlush, qw
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
AsynchronousWriterAppender(org.apache.log4j.Layout layout, OutputStream os, int maxbuf)
          Create an AsynchronousWriterAppender.
 
Method Summary
 void append(org.apache.log4j.spi.LoggingEvent event)
          Hand over a log event to be posted as soon as possible.
 void close()
          This method will close underlying streams and free used resources.
 void post(Object event)
          Actually post a message into the underlying logging system.
 String toString()
           
 
Methods inherited from class org.apache.log4j.WriterAppender
activateOptions, checkEntryConditions, closeWriter, createWriter, getEncoding, getImmediateFlush, requiresLayout, reset, setEncoding, setErrorHandler, setImmediateFlush, setWriter, subAppend, writeFooter, writeHeader
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dispatcher_

private AbstractAsynchronousMessageDispatcher dispatcher_
The Asynchronous Message Dispatcher thread


closed_

private boolean closed_
This flag will be set to true once close() has been called

Constructor Detail

AsynchronousWriterAppender

public AsynchronousWriterAppender(org.apache.log4j.Layout layout,
                                  OutputStream os,
                                  int maxbuf)
Create an AsynchronousWriterAppender.

Parameters:
layout - The layout to be used for message formatting
os - The underlying output stream
maxbuf - The maximum number of messages that can be stored in the internal buffer (must be at least 1)
Throws:
IllegalArgumentException - if the maximum buffer size is less than 1
Method Detail

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Hand over a log event to be posted as soon as possible.

Parameters:
event - The log event to be appended

post

public void post(Object event)
Description copied from interface: Messenger
Actually post a message into the underlying logging system.

Specified by:
post in interface Messenger
Parameters:
event - The message to post

close

public void close()
This method will close underlying streams and free used resources. When it returns, all events will have been written by the included AbstractAsynchronousMessageDispatcher.

Specified by:
close in interface org.apache.log4j.Appender

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.