org.castor.tools.log4j

Class CastorAppender

public final class CastorAppender extends 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.

Constructor Summary
CastorAppender()
Default constructor.
Method Summary
voidappend(LoggingEvent event)
Adds the event to the buffer.
voidclose()
Closes the appender, flushing the buffer first then closing the query and database if it is still open.
voidfinalize()
Closes the appender before disposal.
static voidflush()
When the program has ended all logger instances are destroyed.
intgetBufferSize()
Get the size of the buffer.
intgetColumnWidthClass()
Get the column width for class information.
intgetColumnWidthMessage()
Get the column width for message information.
intgetColumnWidthStackTrace()
Get the column width for stack trace information.
intgetColumnWidthThread()
Get the column width for tread information.
StringgetDatabaseName()
Get the name of the database.
StringgetDuplicateCount()
Is duplicate count enabled?
booleanrequiresLayout()
CastorAppender don't requires a layout.
voidsetBufferSize(int newBufferSize)
Set the size of the buffer.
voidsetColumnWidthClass(int columWidth)
Set the column width for class information.
voidsetColumnWidthMessage(int columWidth)
Set the column width for message information.
voidsetColumnWidthStackTrace(int columWidth)
Set the column width for stack trace information.
voidsetColumnWidthThread(int columWidth)
Set the column width for thread information.
voidsetDatabaseName(String name)
Set the name of the database.
voidsetDuplicateCount(String duplicateCount)
Set duplicate count.

Constructor Detail

CastorAppender

public CastorAppender()
Default constructor.

Method Detail

append

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

Parameters: event The event to be logged.

close

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

finalize

public void finalize()
Closes the appender before disposal.

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.

getBufferSize

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

Returns: The size of the buffer.

getColumnWidthClass

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

Returns: The column width for class information.

getColumnWidthMessage

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

Returns: The column width for message information.

getColumnWidthStackTrace

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

Returns: The column width for stack trace information.

getColumnWidthThread

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

Returns: The column width for thread information.

getDatabaseName

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

Returns: Name of the database.

getDuplicateCount

public String getDuplicateCount()
Is duplicate count enabled?

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

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.

setColumnWidthClass

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

Parameters: columWidth The column width for class information.

setColumnWidthMessage

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

Parameters: columWidth 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.

setColumnWidthThread

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

Parameters: columWidth The column width for thread information.

setDatabaseName

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

Parameters: name Name of the database.

setDuplicateCount

public void setDuplicateCount(String duplicateCount)
Set duplicate count.

Parameters: duplicateCount Should duplicate count be enabled?

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