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

void
append(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.
String
getDatabaseName()
Get the name of the database.
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(String name)
Set the name of the database.
void
setDuplicateCount(String duplicateCount)
Set duplicate count.

Constructor Details

CastorAppender

public CastorAppender()
Default constructor.

Method Details

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