Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-631

Preferably don't call toString() on objects in arguments array

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 0.9.19
    • logback-classic
    • None
    • Software platform

    Description

      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); }

      }

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            donaldgraham Donald Graham
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: