logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: Logging stack trace to a Database
Date Sun, 09 May 2004 13:23:57 GMT

James,

To support exceptions, create a new table and handle the exception data in 
a similar way to the insertion of  MDC properties.

Does this help?

At 08:39 PM 5/6/2004, James Stauffer wrote:

>I would like my log messages logged to a Database with the stack 
>trace.  It appears DBAppender (in 1.3) doesn't do that.  What is the best 
>way to accomplish that?  I am willing to do the coding.  Two ideas that I 
>had are:
>
>1. Change DBAppender to support another column for the stack trace.
>    Pro: Should be easy to do.
>    Con: Would everyone want the stack trace?
>         Right now there is no way for a user to choose what they want so 
> the user couldn't decide to not get the stack trace.
>
>2. Make a new Database Appender (let's call it DBAppender2 for now).
>    Pro: Could code to allow the user to decide what goes in the Database.
>         The autoincrementing sequence issue wouldn't matter in log4j 
> (sqlDialect.getSelectInsertId()).
>         The only mandatory option would be "TableName".
>         All other options would be interpreted as column names with the 
> value of the option being passed through the layout class. Example:
>
>   <param name="TableName" value="logging_event" />
>   <param name="message" value="%m" />
>   <param name="catagory" value="%c" />
>   <param name="Thread" value="%t" />
>   <param name="machine" value="machine" /><!-- different machines would 
> have different values here in their log4j.xml -->
>
>   <param name="Priority" value="%p" />
>   <param name="Time" value="%d" />
>   <param name="Short_Message" value="%p @ %d: %m" />
>   <param name="URL" value="%X{url}" />
>   <param name="stack" value="%throwable" />
>
>   Con: Lots more coding.
>         More complex.
>         Stack traces can be long so how would that be handled so that 
> overflow wouldn't prevent logging.
>         Are arbitrary options supported?
>         Would everyting have to go in the Database as a string?
>         How would dates and sequence numbers be handled?
>         Could we treat the value as a date if(value.startsWith(%d) || 
> (value.startsWith(%d{) && value.indexOf("}") == value.length()))?
>
>Comments?
>
>James Stauffer
>

-- 
Ceki Gülcü

      For log4j documentation consider "The complete log4j manual"
      ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp  



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


Mime
View raw message