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 Thomas Svensen <ts...@cellus.no> on 2003/09/17 15:01:47 UTC
RE: Why is ThrowableInformation transient in LoggingEvent?
Hello Ceki,
thank you for your answer.
Finally I have got some time to look into it, and you are right, the String
representation within ThrowableInfo is not transient. But it does not solve
my problem, still :-(
ThrowableInfo seems to do a lazy initialization of the String
representation, thus a call to getThrowableStrRep seems to go via the
Throwable to extract the stack trace for the exception. Subsequent calls
probably go straight to String[], I assume.
Why is this a problem?
I want to log from an application via a SocketAppender to a central
SocketServer which subsequently does calls to JDBCAppender to get the log
into a database. But once the JDBCAppender gets the LoggingEvent, there are
no signs of a stack trace anymore.
So, what can I do? Is there any way I can force the initialization of the
String representation before I serialize the LoggingEvent off to be sent via
the socket? (Apart from writing my own implementation, which I consider a
very last resort :-)
- Thomas S.
> -----Original Message-----
> From: Ceki Gulcu [mailto:ceki@qos.ch]
> Sent: 25. august 2003 08:52
> To: Log4J Users List
> Subject: Re: Why is ThrowableInformation transient in LoggingEvent?
>
>
> Thomas ,
>
> The throwables do not preserve the stack trace after
> serialization, so they
> are useless on the server side. That is why the throwable variable is
> transient. However, there is another variable, throwableInfo, which
> preserves stack trace information after serialization. By the
> way, we are
> talking about stack traces of exceptions, right?
>
>
>
> At 07:59 AM 8/25/2003 +0200, Thomas Svensen wrote:
> >Hi fellow "loggers"!
> >
> >I am setting up a logging scheme where a number of "satelite
> systems" report
> >logging events via sockets to a central logger. I will only send events
> >about a certain level, e.g. ERROR.
> >
> >This was very easy and simple to set up, but one problem arose:
> I couldn't
> >see the stack trace in the central logger. I read the javadoc
> and found the
> >following under LoggingEvent:
> >
> >------------ javadoc start ------------------
> >
> >public ThrowableInformation getThrowableInformation()
> >Returns the throwable information contained within this event.
> May be null
> >if there is no such information.
> >
> >Note that the Throwable object contained within a
> ThrowableInformation does
> >not survive serialization.
> >
> >------------ javadoc end ------------------
> >
> >Why has ThrowableInformation been declared transient? For performance
> >reasons? Is there a simpler solution to this than writing my own
> >LoggingEvent and other required classes?
> >
> >Thanks for any feedback on this :-)
> >
> >
> >Thomas Svensen
> >-------------------------------------
> >System Developer
> >Cellus Norway
> >mailto:thomas.svensen@cellus.no
> >fixed line: (+47) 23 23 44 25
> >mobile: (+47) 918 23 480
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
> --
> Ceki For log4j documentation consider "The complete log4j manual"
> ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org
RE: Why is ThrowableInformation transient in LoggingEvent?
Posted by Thomas Svensen <ts...@cellus.no>.
Hello "loggers"!
I will reply to my own request since
a) noone else answered me
b) and I figured out the problem :-)
OK, the whole problem is within the JDBCAppender that I downloaded from
apache/Jakarta. The problem is that it "re-creates" the LoggingEvent (twice,
actually), using the Throwable from the original LoggingEvent. Thus, the
stack trace is lost.
I have sent updated source files to Mr. Danko Mannhaupt, who seems to be in
charge of this extended JDBCAppender.
- Thomas S.
> -----Original Message-----
> From: Thomas Svensen [mailto:tsv@cellus.no]
> Sent: 17. september 2003 15:02
> To: Log4J Users List
> Subject: RE: Why is ThrowableInformation transient in LoggingEvent?
>
>
> Hello Ceki,
>
> thank you for your answer.
>
> Finally I have got some time to look into it, and you are right,
> the String
> representation within ThrowableInfo is not transient. But it does
> not solve
> my problem, still :-(
>
> ThrowableInfo seems to do a lazy initialization of the String
> representation, thus a call to getThrowableStrRep seems to go via the
> Throwable to extract the stack trace for the exception. Subsequent calls
> probably go straight to String[], I assume.
>
> Why is this a problem?
>
> I want to log from an application via a SocketAppender to a central
> SocketServer which subsequently does calls to JDBCAppender to get the log
> into a database. But once the JDBCAppender gets the LoggingEvent,
> there are
> no signs of a stack trace anymore.
>
> So, what can I do? Is there any way I can force the initialization of the
> String representation before I serialize the LoggingEvent off to
> be sent via
> the socket? (Apart from writing my own implementation, which I consider a
> very last resort :-)
>
> - Thomas S.
>
> > -----Original Message-----
> > From: Ceki Gulcu [mailto:ceki@qos.ch]
> > Sent: 25. august 2003 08:52
> > To: Log4J Users List
> > Subject: Re: Why is ThrowableInformation transient in LoggingEvent?
> >
> >
> > Thomas ,
> >
> > The throwables do not preserve the stack trace after
> > serialization, so they
> > are useless on the server side. That is why the throwable variable is
> > transient. However, there is another variable, throwableInfo, which
> > preserves stack trace information after serialization. By the
> > way, we are
> > talking about stack traces of exceptions, right?
> >
> >
> >
> > At 07:59 AM 8/25/2003 +0200, Thomas Svensen wrote:
> > >Hi fellow "loggers"!
> > >
> > >I am setting up a logging scheme where a number of "satelite
> > systems" report
> > >logging events via sockets to a central logger. I will only send events
> > >about a certain level, e.g. ERROR.
> > >
> > >This was very easy and simple to set up, but one problem arose:
> > I couldn't
> > >see the stack trace in the central logger. I read the javadoc
> > and found the
> > >following under LoggingEvent:
> > >
> > >------------ javadoc start ------------------
> > >
> > >public ThrowableInformation getThrowableInformation()
> > >Returns the throwable information contained within this event.
> > May be null
> > >if there is no such information.
> > >
> > >Note that the Throwable object contained within a
> > ThrowableInformation does
> > >not survive serialization.
> > >
> > >------------ javadoc end ------------------
> > >
> > >Why has ThrowableInformation been declared transient? For performance
> > >reasons? Is there a simpler solution to this than writing my own
> > >LoggingEvent and other required classes?
> > >
> > >Thanks for any feedback on this :-)
> > >
> > >
> > >Thomas Svensen
> > >-------------------------------------
> > >System Developer
> > >Cellus Norway
> > >mailto:thomas.svensen@cellus.no
> > >fixed line: (+47) 23 23 44 25
> > >mobile: (+47) 918 23 480
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> >
> > --
> > Ceki For log4j documentation consider "The complete log4j manual"
> > ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org