logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Stauffer <jstau...@spscommerce.com>
Subject Logging stack trace to a Database
Date Thu, 06 May 2004 18:39:45 GMT
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
 

Mime
View raw message