org.castor.tools.log4j
Class CastorAppender

java.lang.Object
  extended byorg.apache.log4j.AppenderSkeleton
      extended byorg.castor.tools.log4j.CastorAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public final class CastorAppender
extends org.apache.log4j.AppenderSkeleton

The CastorAppender provides sending log events to a database.

Each append call adds the LoggingEvent to an ArrayList buffer. When the buffer is filled each log event is saved to the database. DatabaseName, BufferSize, ColumnWidthClass, ColumnWidthThread, ColumnWidthMessage, ColumnWidthStackTrace and DuplicateCount are configurable options in the standard log4j ways.

Version:
$Id: TNSAddress.java,v 1.2 2006/08/08 14:42:48 holger Exp $
Author:
Holger West, Syscon Ingenieurbüro für Mess- und Datentechnik GmbH.

Field Summary
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
Constructor Summary
CastorAppender()
          Default constructor.
 
Method Summary
 void append(org.apache.log4j.spi.LoggingEvent event)
          Adds the event to the buffer.
 void close()
          Closes the appender, flushing the buffer first then closing the query and database if it is still open.
 void finalize()
          Closes the appender before disposal.
static void flush()
          When the program has ended all logger instances are destroyed.
 int getBufferSize()
          Get the size of the buffer.
 int getColumnWidthClass()
          Get the column width for class information.
 int getColumnWidthMessage()
          Get the column width for message information.
 int getColumnWidthStackTrace()
          Get the column width for stack trace information.
 int getColumnWidthThread()
          Get the column width for tread information.
 java.lang.String getDatabaseName()
          Get the name of the database.
 java.lang.String getDuplicateCount()
          Is duplicate count enabled?
 boolean requiresLayout()
          CastorAppender don't requires a layout.
 void setBufferSize(int newBufferSize)
          Set the size of the buffer.
 void setColumnWidthClass(int columWidth)
          Set the column width for class information.
 void setColumnWidthMessage(int columWidth)
          Set the column width for message information.
 void setColumnWidthStackTrace(int columWidth)
          Set the column width for stack trace information.
 void setColumnWidthThread(int columWidth)
          Set the column width for thread information.
 void setDatabaseName(java.lang.String name)
          Set the name of the database.
 void setDuplicateCount(java.lang.String duplicateCount)
          Set duplicate count.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CastorAppender

public CastorAppender()
Default constructor.

Method Detail

flush

public static void flush()
When the program has ended all logger instances are destroyed. To save all data which are still in the buffer, this method must be called. It saves all data from all registered CastorAppender.
As an alternative org.apache.log4j.LogManager.shutdown() can be called.


finalize

public void finalize()
Closes the appender before disposal.


close

public void close()
Closes the appender, flushing the buffer first then closing the query and database if it is still open.


append

public void append(org.apache.log4j.spi.LoggingEvent event)
Adds the event to the buffer. When full the buffer is flushed.

Parameters:
event - The event to be logged.

requiresLayout

public boolean requiresLayout()
CastorAppender don't requires a layout.

Returns:
true if this appender require a layout, otherwise false.

setBufferSize

public void setBufferSize(int newBufferSize)
Set the size of the buffer.

Parameters:
newBufferSize - New size of the buffer.

getBufferSize

public int getBufferSize()
Get the size of the buffer.

Returns:
The size of the buffer.

setDatabaseName

public void setDatabaseName(java.lang.String name)
Set the name of the database.

Parameters:
name - Name of the database.

getDatabaseName

public java.lang.String getDatabaseName()
Get the name of the database.

Returns:
Name of the database.

setColumnWidthClass

public void setColumnWidthClass(int columWidth)
Set the column width for class information.

Parameters:
columWidth - The column width for class information.

getColumnWidthClass

public int getColumnWidthClass()
Get the column width for class information.

Returns:
The column width for class information.

setColumnWidthThread

public void setColumnWidthThread(int columWidth)
Set the column width for thread information.

Parameters:
columWidth - The column width for thread information.

getColumnWidthThread

public int getColumnWidthThread()
Get the column width for tread information.

Returns:
The column width for thread information.

setColumnWidthMessage

public void setColumnWidthMessage(int columWidth)
Set the column width for message information.

Parameters:
columWidth - The column width for message information.

getColumnWidthMessage

public int getColumnWidthMessage()
Get the column width for message information.

Returns:
The column width for message information.

setColumnWidthStackTrace

public void setColumnWidthStackTrace(int columWidth)
Set the column width for stack trace information.

Parameters:
columWidth - The column width for stack trace information.

getColumnWidthStackTrace

public int getColumnWidthStackTrace()
Get the column width for stack trace information.

Returns:
The column width for stack trace information.

setDuplicateCount

public void setDuplicateCount(java.lang.String duplicateCount)
Set duplicate count.

Parameters:
duplicateCount - Should duplicate count be enabled?

getDuplicateCount

public java.lang.String getDuplicateCount()
Is duplicate count enabled?

Returns:
true if duplicate count is enabled, otherwise false.


Intalio Inc. (C) 1999-2007. All rights reserved http://www.intalio.com