logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tnms04 bln <bln.tnm...@mchh.siemens.de>
Subject AW: Logging stack trace to a Database
Date Fri, 07 May 2004 09:33:55 GMT
You might also want to check
http://www.dankomannhaupt.de/projects/index.html <http://www.dankomannhaupt.de/projects/index.html>

which supports logging the stacktrace and works kind of like you 2nd suggestion.


Von: James Stauffer [mailto:jstauffe@spscommerce.com] 
Gesendet: Donnerstag, 6. Mai 2004 20:40
An: 'log4j-dev@logging.apache.org'
Betreff: Logging stack trace to a Database

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
        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()))?


James Stauffer 

View raw message