org.apache.turbine.services.logging.jdbc
Class JDBCAppender

java.lang.Object
  |
  +--org.apache.log4j.AppenderSkeleton
        |
        +--org.apache.turbine.services.logging.jdbc.JDBCAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class JDBCAppender
extends org.apache.log4j.AppenderSkeleton

The JDBCAppender, writes messages into a database. The JDBCAppender is configurable at runtime by setting options in two alternatives :

Author:
Thomas Fenner, Jason van Zyl

Field Summary
private  java.util.ArrayList buffer
          Hold bin for messages that need to be pushed into the database into which we are logging.
private  int bufferSize
          How many messages should we buffer until to push the messages into the database.
private  JDBCLogger logger
           
static java.lang.String LOGGER_CLASS_OPTION
          Logger class option.
static java.lang.String LOGGER_OPTION
          An option to set for the logger, these are name:value pairs that are used to initialize a logger.
private  java.lang.String loggerClass
          Logger class to instantiate for logging to a database.
private  java.util.Hashtable loggerOptions
          Hashtable of options that are used to initialize the logger being used.
private  boolean ready
           
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION
 
Constructor Summary
JDBCAppender()
           
 
Method Summary
 void activateOptions()
          Active our logger to be used for appending messages to the database.
 void append(org.apache.log4j.spi.LoggingEvent event)
          Internal method.
 void close()
          Internal method.
 void finalize()
          If program terminates close the database-connection and flush the buffer.
 void flushBuffer()
          Internal method.
 java.lang.String[] getOptionStrings()
          Internal method.
 boolean isReady()
          Internal method.
 boolean requiresLayout()
          Internal method.
 void setOption(java.lang.String option, java.lang.String value)
          Sets all necessary options
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
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, registerNatives, toString, wait, wait, wait
 

Field Detail

LOGGER_CLASS_OPTION

public static final java.lang.String LOGGER_CLASS_OPTION
Logger class option.

LOGGER_OPTION

public static final java.lang.String LOGGER_OPTION
An option to set for the logger, these are name:value pairs that are used to initialize a logger.

loggerClass

private java.lang.String loggerClass
Logger class to instantiate for logging to a database.

loggerOptions

private java.util.Hashtable loggerOptions
Hashtable of options that are used to initialize the logger being used.

logger

private JDBCLogger logger

buffer

private java.util.ArrayList buffer
Hold bin for messages that need to be pushed into the database into which we are logging.

bufferSize

private int bufferSize
How many messages should we buffer until to push the messages into the database.

ready

private boolean ready
Constructor Detail

JDBCAppender

public JDBCAppender()
Method Detail

finalize

public void finalize()
If program terminates close the database-connection and flush the buffer.
Overrides:
finalize in class org.apache.log4j.AppenderSkeleton

getOptionStrings

public java.lang.String[] getOptionStrings()
Internal method. Returns a array of strings containing the available options which can be set with method setOption()
Overrides:
getOptionStrings in class org.apache.log4j.AppenderSkeleton

setOption

public void setOption(java.lang.String option,
                      java.lang.String value)
Sets all necessary options
Overrides:
setOption in class org.apache.log4j.AppenderSkeleton
Parameters:
String - option
String - value

activateOptions

public void activateOptions()
Active our logger to be used for appending messages to the database.
Overrides:
activateOptions in class org.apache.log4j.AppenderSkeleton

requiresLayout

public boolean requiresLayout()
Internal method. Returns true, you may define your own layout...
Overrides:
requiresLayout in class org.apache.log4j.AppenderSkeleton
Returns:
boolean

close

public void close()
Internal method. Close the database connection & flush the buffer.
Overrides:
close in class org.apache.log4j.AppenderSkeleton

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Internal method. Appends the message to the database table.
Overrides:
append in class org.apache.log4j.AppenderSkeleton
Parameters:
LoggingEvent - event

flushBuffer

public void flushBuffer()
Internal method. Flushes the buffer.

isReady

public boolean isReady()
Internal method. Returns true, when the JDBCAppender is ready to append messages to the database, else false.
Returns:
boolean


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.