[logback-dev] [JIRA] Commented: (LBCLASSIC-201) Preferably don't call toString() on objects in arguments array
Joern Huxhorn (JIRA)
noreply-jira at qos.ch
Wed Apr 7 10:27:16 CEST 2010
[ http://jira.qos.ch/browse/LBCLASSIC-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11714#action_11714 ]
Joern Huxhorn commented on LBCLASSIC-201:
-----------------------------------------
How about leaving the current SocketAppender as it is and implementing any more complex logic in a different SocketAppender implementation?
I really think that most use-cases of the SocketAppender won't need serialized parameters and changing the behavior of SocketAppender will render current receivers broken.
This might be a use-case for a different LoggingEventVO implementation.
readResolve is called after successful deserialization. you'd need to implement readObject and writeObject in a way that handles the parameters manually, declaring them transient in the class.
One remaining problem will be that any parameters that throw a ClassNotFoundException while deserializing won't be available in the parameters array, obviously.
Those may have included very important information that won't show up in the log message anymore, though!
All of this is making me a bit nervous... that's why I'd suggest to keep the KISS implementation of SocketAppender and putting anything else into a completely different one, instead.
> Preferably don't call toString() on objects in arguments array
> --------------------------------------------------------------
>
> Key: LBCLASSIC-201
> URL: http://jira.qos.ch/browse/LBCLASSIC-201
> Project: logback-classic
> Issue Type: Improvement
> Components: appender
> Affects Versions: 0.9.19
> Environment: Software platform
> Reporter: Donald Graham
> Assignee: Ceki Gulcu
> Attachments: SerializationTest.java
>
>
> I'm attempting to use a SocketAppender to send log events over the network to a custom appender hosted by SimpleSocketServer. My custom appender needs to work with my arguments as objects, rather than strings. I noticed that the string representations of my arguments were being passed across the network, and traced through to the code shown below (from ch.qos.logback.classic.spi.LoggingEventVO). Would you consider sending the object's serialized form instead (assuming the object is serializable)?
> private void writeObject(ObjectOutputStream out) throws IOException {
> out.defaultWriteObject();
> out.writeInt(level.levelInt);
> if (argumentArray != null) {
> int len = argumentArray.length;
> out.writeInt(len);
> for (int i = 0; i < argumentArray.length; i++) {
> if (argumentArray[i] != null) {
> out.writeObject(argumentArray[i].toString());
> } else {
> out.writeObject(NULL_ARGUMENT_ARRAY_ELEMENT);
> }
> }
> } else {
> out.writeInt(NULL_ARGUMENT_ARRAY);
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list