logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 48220] LoggingEvent.mdcCopy serialization with non-serializable MDC-values
Date Thu, 19 Nov 2009 10:16:10 GMT

--- Comment #3 from Lars Beuster <lbe.tech@spree.de> 2009-11-19 02:16:07 UTC ---
Yes, the toString()-call could be a good idea and would solve the problem for
non-serializable values.

But I had also another problem. I've put my own serializable object into the
MDC-context. But it couldn't be deserialized at the other side because my
classfile wasn't present there.
In my special case I've put an application object into the MDC-context. I
didn't want to use the toString()-presentation because this method was too
heavy. My object was only used in an ErrorAppender with a PatternLayout that
used the MDC-value. So toString() was only called in an error case.
Another developer had a SocketAppender in his log4j.xml in conjunction with
log4eclipse as the server socket - and ran into the problem.

So for now I've created a SocketAppender-subclass that modifies the
LoggingEvent by replacing the mdcCopy-values with it's
toString()-representations - per reflection because the fields are private. The
heavy toString()-method of my object is now called on every logging event (not
only in an error case) - but that's ok, since it's a developer system.

But I don't know if this is a solution that is suitable for everybody using
log4j. Perhaps it's possible to activate this behavior with a special option
(global or local on every serializing appender).


Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

View raw message