views:

1564

answers:

3

Since in log4j javadoc is

WARNING: This version of JDBCAppender is very likely to be completely replaced in the future. Moreoever, it does not log exceptions.

What should I do to log to a database?

+1  A: 

How about this one?

skaffman
+4  A: 

You can use an alternative appender, but really Log4j 1.2 is going to be around and standard for a long time. They developed DBAppender as part of their receivers companions, which isn't officially released, but you can download the source code and get your own going as well.

Unless the issue of not logging exceptions bothers you, JDBCAppender is just fine. Any further upgrade to 2.0 is going to be more radical than just changing JDBCAppender (if 2.0 happens), so I wouldn't worry about using it, despite the warning. They clearly don't have a solid roadmap or timeline to introducing a new version, and 1.2.15 was released in 2007.

Yishai
+4  A: 

If you are looking for an database appender which not only works, but also supports connection pooling, is maintained and properly documented, than consider logback's DBAppender.

Ironically enough, the warning in the javadocs about removing JDBCAppender in future versions of log4j was written by me.

Ceki