You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Joe Sackett <jo...@sackett.com> on 2001/09/27 03:00:29 UTC

Custom Error Object into JDBCAppender

Although the JDBCAppender is still an add-on to the
current version, I thought that maybe someone knew
how to handle this requirement of ours...
We need to pass an error context object containing
fields "keying" the location of and information about
the problem.  The key and it's error description are
then written to both a log file and the database.
The difference being that while the whole error is
flattened to a string for placement in the log file,
the key and the information goes into separate fields
of the database.  How can the fields of an error object
be passed from the category i.e.:
cat.error( new DeliveryError ( route, date, error_desc ) );
and wind-up in:
JDBCSqlHandler.getStatement ( LoggingEvent event )

Any help would be greatly appreciated.
- Joe



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: Custom Error Object into JDBCAppender

Posted by Kevin Steppe <ks...@pacbell.net>.
Joe,

You could try the JDBCAppender I contributed
(/contribs/KevinSteppe/JDBCAppender), which allows the SQL to be
generated using a PatternLayout to extract the different portions of an
error object into different database table columns (or even different
tables if you write some complicated SQL).  If your event object has
fields that the standard PatternLayout doesn't have you'll need to extend
PatternLayout to handle them.  I'd be happy to help you if that doesn't
solve the problem.

Kevin


Joe Sackett wrote:

> Although the JDBCAppender is still an add-on to the
> current version, I thought that maybe someone knew
> how to handle this requirement of ours...
> We need to pass an error context object containing
> fields "keying" the location of and information about
> the problem.  The key and it's error description are
> then written to both a log file and the database.
> The difference being that while the whole error is
> flattened to a string for placement in the log file,
> the key and the information goes into separate fields
> of the database.  How can the fields of an error object
> be passed from the category i.e.:
> cat.error( new DeliveryError ( route, date, error_desc ) );
> and wind-up in:
> JDBCSqlHandler.getStatement ( LoggingEvent event )
>
> Any help would be greatly appreciated.
> - Joe
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org