org.apache.log4j.db
クラス DBAppender

java.lang.Object
  上位を拡張 org.apache.log4j.AppenderSkeleton
      上位を拡張 org.apache.log4j.db.DBAppender
すべての実装されたインタフェース:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler, org.apache.log4j.xml.UnrecognizedElementHandler

public class DBAppender
extends org.apache.log4j.AppenderSkeleton
implements org.apache.log4j.xml.UnrecognizedElementHandler

The DBAppender inserts loggin events into three database tables in a format independent of the Java programming language. The three tables that DBAppender inserts to must exists before DBAppender can be used. These tables may be created with the help of SQL scripts found in the src/java/org/apache/log4j/db/dialect directory. There is a specific script for each of the most popular database systems. If the script for your particular type of database system is missing, it should be quite easy to write one, taking example on the already existing scripts. If you send them to us, we will gladly include missing scripts in future releases.

If the JDBC driver you are using supports the Statement.getGeneratedKeys()method introduced in JDBC 3.0 specification, then you are all set. Otherwise, there must be an SQLDialectappropriate for your database system. Currently, we have dialects for PostgreSQL, MySQL, Oracle and MsSQL. As mentioed previously, an SQLDialect is required only if the JDBC driver for your database system does not support the getGeneratedKeys method.

RDBMS supports
getGeneratedKeys() method
specific
SQLDialect support
PostgreSQL NO present and used
MySQL YES present, but not actually needed or used
Oracle YES present, but not actually needed or used
DB2 YES not present, and not needed or used
MsSQL YES not present, and not needed or used
HSQL NO present and used

Performance: Experiments show that writing a single event into the database takes approximately 50 milliseconds, on a "standard" PC. If pooled connections are used, this figure drops to under 10 milliseconds. Note that most JDBC drivers already ship with connection pooling support.

Configuration DBAppender can be configured programmatically, or using JoranConfigurator. Example scripts can be found in the tests/input/db directory.

作成者:
Ceki Gülcü, Ray DeCampo

フィールドの概要
 
クラス org.apache.log4j.AppenderSkeleton から継承されたフィールド
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
コンストラクタの概要
DBAppender()
           
 
メソッドの概要
 void activateOptions()
           
protected  void append(org.apache.log4j.spi.LoggingEvent event)
           
 void close()
           
 ConnectionSource getConnectionSource()
           
 boolean getLocationInfo()
          Returns value of the LocationInfo property which determines whether caller's location info is written to the database.
 boolean parseUnrecognizedElement(org.w3c.dom.Element element, java.util.Properties props)
           
 boolean requiresLayout()
          Gets whether appender requires a layout.
 void setConnectionSource(ConnectionSource connectionSource)
           
 void setLocationInfo(boolean locationInfo)
          If true, the information written to the database will include caller's location information.
 
クラス org.apache.log4j.AppenderSkeleton から継承されたメソッド
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
クラス java.lang.Object から継承されたメソッド
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

DBAppender

public DBAppender()
メソッドの詳細

activateOptions

public void activateOptions()
定義:
インタフェース org.apache.log4j.spi.OptionHandler 内の activateOptions
オーバーライド:
クラス org.apache.log4j.AppenderSkeleton 内の activateOptions

getConnectionSource

public ConnectionSource getConnectionSource()
戻り値:
Returns the connectionSource.

setConnectionSource

public void setConnectionSource(ConnectionSource connectionSource)
パラメータ:
connectionSource - The connectionSource to set.

append

protected void append(org.apache.log4j.spi.LoggingEvent event)
定義:
クラス org.apache.log4j.AppenderSkeleton 内の append

close

public void close()
定義:
インタフェース org.apache.log4j.Appender 内の close

getLocationInfo

public boolean getLocationInfo()
Returns value of the LocationInfo property which determines whether caller's location info is written to the database.


setLocationInfo

public void setLocationInfo(boolean locationInfo)
If true, the information written to the database will include caller's location information. Due to performance concerns, by default no location information is written to the database.


requiresLayout

public boolean requiresLayout()
Gets whether appender requires a layout.

定義:
インタフェース org.apache.log4j.Appender 内の requiresLayout
戻り値:
false

parseUnrecognizedElement

public boolean parseUnrecognizedElement(org.w3c.dom.Element element,
                                        java.util.Properties props)
                                 throws java.lang.Exception
定義:
インタフェース org.apache.log4j.xml.UnrecognizedElementHandler 内の parseUnrecognizedElement
例外:
java.lang.Exception


Copyright © 2010 Apache Software Foundation. All Rights Reserved.