You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "FLYNN, Peter -Syntegra UK" <Pe...@syntegra.com> on 2003/01/21 12:48:24 UTC

transient Throwable object in spi.ThrowableInformation

Hi,

I currently have a set of servers that send out log messages over JMS, using
the JMSAppender. 
I have a Swing based Log4J Log Message Viewer which takes the messages
published to the logging topic, and
displays the relevant details.  

I noticed that when a Throwable object is included in the Log Message, a
ThrowableInformation object is created, but
when deserialised, the Throwable object is null.  After investigation, I
found that the Throwable object under the class
org.apache.log4j.spi.ThrowableInformation had declared the Throwable object
as Transient.  This would mean that
it would not be serialised.  I removed the transient call, and the Throwable
is now serialised and sent over JMS.

Is there a particular reason why it was declared transient?  Was it to keep
the object size down ( a consideration when
serialising over a network connection using JMS).  I can still obtain the
String representation of the stack trace by using the 
API method getThrowableStrRep() in org.apache.log4j.spi.LoggingEvent.

I have included the updated org.apache.log4j.spi.ThrowableInformation class.

Best regards,
Peter



********************************************************************

This email may contain information which is privileged or confidential. If you are not the intended recipient of this email, please notify the sender immediately and delete it without reading, copying, storing, forwarding or disclosing its contents to any other person
Thank you

Check us out at http://www.syntegra.com

********************************************************************


Re: transient Throwable object in spi.ThrowableInformation

Posted by Ceki Gülcü <ce...@qos.ch>.
The reason is that the stack trace of an exception is not transmitted 
through serialization.  Hence we had to convert an exception's stack trace 
to a string array. All appenders manipulate this string array instead of 
the exception. Hope this makes sense.

At 11:48 21.01.2003 +0000, you wrote:

>Hi,
>
>I currently have a set of servers that send out log messages over JMS, 
>using the JMSAppender.
>I have a Swing based Log4J Log Message Viewer which takes the messages 
>published to the logging topic, and
>displays the relevant details.
>
>I noticed that when a Throwable object is included in the Log Message, a 
>ThrowableInformation object is created, but
>when deserialised, the Throwable object is null.  After investigation, I 
>found that the Throwable object under the class
>
>org.apache.log4j.spi.ThrowableInformation had declared the Throwable 
>object as Transient.  This would mean that
>it would not be serialised.  I removed the transient call, and the 
>Throwable is now serialised and sent over JMS.
>
>Is there a particular reason why it was declared transient?  Was it to 
>keep the object size down ( a consideration when
>serialising over a network connection using JMS).  I can still obtain the 
>String representation of the stack trace by using the
>
>API method getThrowableStrRep() in org.apache.log4j.spi.LoggingEvent.
>
>I have included the updated org.apache.log4j.spi.ThrowableInformation class.
>
>Best regards,
>Peter



--
Ceki



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>