>>the problem is LoggingEvent doesn't serialize MessageObject Actually, the issue is that the message object is "rendered" prior to serialization. You could register an ObjectRenderer impl for your custom message object. However, whatever this returns must be a string. You could try something like serializing your custom message object in your renderer into a ByteArrayOutputStream and then return that stream's string representation. That would then get serialized (in that same string format) along with the logging event. Then on the other end, you could get the LoggingEvent, get its message (i.e., your serialized message object) and deserialize it manually.
Seems like an awful lot of effort to get around using MDC/NDC to pass along these attributes. But thats just me... -----Original Message----- From: Sanjay Gupta (sanjaygu) [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 11:16 AM To: 'Log4J Users List' Subject: RE: Serialization of LoggingEvent message field I think you didn't get my question. I have a custom Message object which has additional info such as hostname, applId. I want to send the LoggingEvent over the socket. But the problem is LoggingEvent doesn't serialize MessageObject, so I can not send my Custom Message Object to the other end of the socket. Is there a way I can do it? I could think of 2 ways to do it but I have a road block in each of them - 1. Wrap the LoggingEvent object and My Custom Message object in a serializable wrapper class and transfer that over the wire. Then on the other end, deserialize the wrapper from the stream, pull out the Custom Message 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). But, there is no setter method to set the message object in a LoggingEvent. 2. Xml-ize the LoggingEvent Object and send it over the wire. On the other end re-create the Logging Event but again how do I set LocationInfo. There is no setter method to set the locationInfo. I strongly feel that there should be a way to pass custom parameters to LoggingEvent that can be serialized. Providing a serializable hashtable in LoggingEvent is a good idea. I saw this discussion & suggestion in mailing archive but I don't know what happened. Ability to extend PatternLayout to use custom conversion charcters is a cool feature but then inablity to pass those custom parameters over the socket makes is unusable in distributed environment. -----Original Message----- From: Ebersole, Steven [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 8:43 AM To: 'Log4J Users List' Subject: RE: Serialization of LoggingEvent message field Use the getLocationInformation() method on LoggingEvent prior to serializing... -----Original Message----- From: Sanjay Gupta (sanjaygu) [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 10:37 AM To: 'Steve Ebersole'; 'Log4J Users List' Subject: RE: Serialization of LoggingEvent message field My opologies, I meant LocationInfo. -Sanjay -----Original Message----- From: Steve Ebersole [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 6:02 PM To: Log4J Users List; [EMAIL PROTECTED] Subject: RE: Serialization of LoggingEvent message field What do you mean by "Localization Info"? Are you talking about the LocationInfo object? Or some kind of custom i18n/localized data? -----Original Message----- From: Sanjay Gupta (sanjaygu) [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 8:04 PM To: [EMAIL PROTECTED] Subject: Serialization of LoggingEvent message field Hi, I am sending the LoggingEvent over wire (SocketAppender). The message object in my case is a custom object I 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 the fact that message object in a LoggingEvent is not serialized. So, how do I send the LoggingEvent with my Custom Message Object. Here is what I tried - 1. One solution I 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. 2. Another solution I came up with was to xml-ize the LoggingEvent Object info and then create a LoggingEvent object on the other end. But then how do I set Localization Info? Anone has any thoughts how to achieve this? Regards, -SAnjay --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]