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 Mike Miller <Mi...@jda.com> on 2006/12/19 06:31:22 UTC

JDBCAppender with large message values

Hi,
 
I want to include the JDBCAppender as one of our appenders so that all error level messages will be written to a common database.  The problem is that the message content frequently contains a stack trace which is too large for the database column.  What I get right now is a row with the 'message' column empty/null.
 
I looked at extending JDBCAppender doAppend method, which would check the length of the message and truncate it after the first X bytes but the LogEvent doesn't provide getters so that I could create a different LogEvent with the truncated message.
 
What I really want to be able to do is use a format modifier on the message column, something like %2048m
to get the first 2k bytes for the column.
 
Any suggestions on other ways to get this implemented?
 

Re: JDBCAppender with large message values

Posted by Mattias Andersson <ma...@caleotech.com>.
Hi,

> Hi,
>
> I want to include the JDBCAppender as one of our appenders so that all
> error level messages will be written to a common database.  The problem is
> that the message content frequently contains a stack trace which is too
> large for the database column.  What I get right now is a row with the
> 'message' column empty/null.
>
> I looked at extending JDBCAppender doAppend method, which would check the
> length of the message and truncate it after the first X bytes but the
> LogEvent doesn't provide getters so that I could create a different
> LogEvent with the truncated message.
>
> What I really want to be able to do is use a format modifier on the
> message column, something like %2048m
> to get the first 2k bytes for the column.
>
> Any suggestions on other ways to get this implemented?
>
Use SUBSTRING in the INSERT statment perhaps?

INSERT INTO LOG_MESSAGES(Message) VALUES(SUBSTRING('%m', 0, 2048))

Regards,
 /Mattias






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