Log4J 1.3alpha0 DBAppender

JakartaCVSからソースを入手してビルド。log4j-1.3alpha0.jarというファイルが出来上がる。INSTALLというファイルに書かれていたサンプルプログラムHelloが動いたので多分大丈夫だろう。

ということで、ソースを眺めてみる。まずDBAppender。これは今の(log4j 1.2.8)のJDBCAppenderと違い、ログの出力先テーブルの名前/フォーマットが固定になる。DB2, HSQLDB, mySQL, Oracle, PostgreSQL用のテーブル定義文が用意されている。

append(LoggingEvent)を見ると、exceptionもlogging_event_exceptionというテーブルへ出力される。両者はevent_idフィールドで関連付けられるようだ。Oracleの場合、そのためのTrigerが上記のテーブル定義文に含まれている。

あとappend()では、PreparedStatementやバッチ実行(addBatch())を使っている。ただPreparedStatementは、append()実行の都度prepareStatement()で生成している。性能的にはどうなんだろう。このクラスのコメントには

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.

とあるけど、この"standard"ってどのくらいのスペックなんだろう。