Hello,

For the moment log4cxx events can persist in a database through the ODBCAppender. This appender has nearly the same features as the JDBCAppender : the database scheme is not fixed, it's configured with the "sql" option which is a format string. This string is changed into an SQL statement by a Layout (the PatternLayout in general).

I agree with you proposal : we should define a common database scheme.

Micha�l

Ceki G�lc� wrote:


Hi all,


For log4j 1.3, I would like DBAppender, i.e. the successor to JDBCAppender, to be able to persist to a database in a format independent of the Java language.

For most fields this is not a problem except for the MDC (a map), properties (a map) and exceptions (an array of type string).

I am thinking of persisting each of these multi-valued fields into their own table. Thus, there will be a table for LoggingEvents containing most fields except for the throwable, MDC and properties.
The MDC field will be stored in its own table, consisting of a foreign key to the owning LoggingEvent instance, a column for the key and a column for the value. Each row in the MDC table will correspond to one (value,key) pair in an MDC instance. The throwable would also be stored in its own table, with each row corresponding to a line in the stack trace. The properties map will be stored in the same way as the MDC.


The advantage over java object serialization is that none of the fields would be opaque for the database and also programming language independent. Thus, one would be able to perform SQL queries on the MDC or the properties. (Give me all the events for userid=john).

Do log4cxx, log4net, or log4pgp support persistence of logging events into a db? Should we work on this in a coordinated fashion?


Reply via email to