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 "Aghanian, Rostom" <ro...@ingrammicro.com> on 2002/08/29 18:47:14 UTC

LoggingEvent message field

Hello,
I have an issue, which looking through Log4J dev archives, seems like a few
others have ran into.  The problem was actually recently brought up by
Torben Brunn in a post titled 'JMS and MDB' on Jul 23, 2002.  The issue was
replied to by Ceki however there were more questions raised then answered.
So here is the issue again and hopefully we can clear things up and maybe
get a solution for my issue.

Actually, before I dive into the details of the issue, let me briefly state
what my main purpose of this post is:  I would like to suggest that a
setMessage(Object message) method be added to the LoggingEvent class.  There
is already a getMessage() object, but no setter. 

Now on with the details.  The issue is the fact that the message object in a
LoggingEvent is not serialized.  Ceki's reply to this was that this is to
avoid the serialization of very large message objects.  And also, he
inquires about the need for serializing this object.  And here is a reason:
the message object in our case is a custom object we created called a
LoggerMessage.  This is a simple container class which holds multiple fields
(all serializable) that we need to transfer over the wire.  Now obviously we
are unable to transfer this due to the LoggingEvent serialization limitation
mentioned above.  So, the solution that we came up with was to wrap the
LoggingEvent object and our LoggerMessage object in a serializable wrapper
class that we created, and transfer that over the wire.  Then on the other
end, we deserialize the wrapper from the stream, pull out the LoggerMessage
and the LoggerEvent out, and assign the LoggerMessage to the LoggingEvent as
its message field (overwriting the String value that it would have after the
serialization process).  However, this is where we ran into our problem.
There is no setter method to set the message object in a LoggingEvent.  And,
looking at the source code of log4j it does not seem possible to easily
reconstruct a new LoggingEvent object from scratch using the fields of
another LoggingEvent object.

Any feedback would be greatly appreciated.
Rostom Aghanian
p.s. sorry for reposting this message but I'm not sure if the last one made
it through.

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