de.fhg.igd.logging.log4j
Class URLAppender

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

public class URLAppender
extends org.apache.log4j.AppenderSkeleton
implements Forwarder

Depending on the configured buffer size, this Appender will open a URLOutputStream which will be linked into either a simple WriterAppender or an AsynchronousWriterAppender which is being wrapped by this class. On dynamic configuration changes, this wrapped Appender might get exchanged accordingly.

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

Field Summary
protected  Integer buffersize_
          The buffer size
private static Set cache_
          The storage for deployed URLAppender objects
private  Chronometer cm_
          The Chronometer that is assigned to the output destination of this Appender
private  int cnt_
          The reference counter
protected  org.apache.log4j.WriterAppender wa_
          The wrapped target WriterAppender
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
protected URLAppender(Chronometer cm)
          Hidden URLAppender construction.
 
Method Summary
 void append(org.apache.log4j.spi.LoggingEvent event)
          Hand over an event to the target Appender.
 void close()
          This method will close underlying streams, remove this Appender from the cache in case no further reference exists.
private static org.apache.log4j.WriterAppender createTarget(OutputStream os, org.apache.log4j.Layout layout, int bufsize)
          Create the target WriterAppender.
 boolean equals(Object obj)
           
(package private) static URLAppender findFor(Chronometer cm)
          Find a URLAppender that has already been created before.
 Integer getBufferSize()
          Get the size of the internal message buffer.
 URL getOutputDestination()
          Get the output destination URL.
 int hashCode()
           
(package private) static URLAppender requestFor(Chronometer cm)
          Request a URLAppender.
 boolean requiresLayout()
           
 String toString()
           
 void updateBufferSize(Integer buffersize)
          Update the size of the internal message buffer.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

cache_

private static Set cache_
The storage for deployed URLAppender objects


cnt_

private int cnt_
The reference counter


cm_

private Chronometer cm_
The Chronometer that is assigned to the output destination of this Appender


buffersize_

protected Integer buffersize_
The buffer size


wa_

protected org.apache.log4j.WriterAppender wa_
The wrapped target WriterAppender

Constructor Detail

URLAppender

protected URLAppender(Chronometer cm)
Hidden URLAppender construction.

Parameters:
cm - The Chronometer that is assigned to the URL to create the Appender for
Throws:
LoggingException - if creating the corresponding URLOutputStream failed
Method Detail

requestFor

static URLAppender requestFor(Chronometer cm)
Request a URLAppender. In case the requested instance has been created before, a reference to the existing instance will be returned and counted.

Parameters:
cm - The Chronometer that is assigned to the URL that the Appender is requested for
Returns:
The requested Appender

findFor

static URLAppender findFor(Chronometer cm)
Find a URLAppender that has already been created before. If no instance could be found for the given Chronometer, null will be returned.

Parameters:
cm - The Chronometer that is assigned to the URL to find the corresponding URLAppender for
Returns:
The requested URLAppender or null if no instance for the given Chronometer has been created yet

createTarget

private static org.apache.log4j.WriterAppender createTarget(OutputStream os,
                                                            org.apache.log4j.Layout layout,
                                                            int bufsize)
Create the target WriterAppender.

Parameters:
os - The underlying output stream
layout - The log event layout
bufsize - The size of the internal message buffer

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Hand over an event to the target Appender.

Parameters:
event - The log event to be appended

requiresLayout

public boolean requiresLayout()
Specified by:
requiresLayout in interface org.apache.log4j.Appender

close

public void close()
This method will close underlying streams, remove this Appender from the cache in case no further reference exists.

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

getOutputDestination

public URL getOutputDestination()
Description copied from interface: Forwarder
Get the output destination URL.

Specified by:
getOutputDestination in interface Forwarder
Returns:
The output destination

getBufferSize

public Integer getBufferSize()
Description copied from interface: Forwarder
Get the size of the internal message buffer. For buffer sizes greater than zero, messages are dispatched asynchronously.

Specified by:
getBufferSize in interface Forwarder
Returns:
The internal message buffer size

updateBufferSize

public void updateBufferSize(Integer buffersize)
Description copied from interface: Forwarder
Update the size of the internal message buffer. For buffer sizes greater than zero, messages will be dispatched asynchronously.

Specified by:
updateBufferSize in interface Forwarder
Parameters:
buffersize - The new size of the internal message buffer

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.