Log4j 2
  1. Log4j 2
  2. LOG4J2-181

SocketAppender reconnection doesn't work


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta4
    • Fix Version/s: 2.0-beta5
    • Component/s: Appenders
    • Labels:


      This issue was actually reported by Werner Goeschl on the developers mailing list.

      We configured a SocketAppender with a reconnectionDelay and defaultLayout (SerializedLayout) in a XML-Config File.
      After starting the application, the SocketAppender tries to open the socket periodical.
      As the next step, we start the application with the SocketServer, and so the Appender connects to it.
      But after we get the following Exception, when we will open the ObjectInputStream (final ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());

      Exception in thread "Thread-2" java.lang.RuntimeException: java.io.StreamCorruptedException: invalid stream header: 7372003E
      at test.logger.LoggerTest_1$TCPSocketServer.run(LoggerTest_1.java:83)
      Caused by: java.io.StreamCorruptedException: invalid stream header: 7372003E
      at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
      at java.io.ObjectInputStream.<init>(Unknown Source)
      at test.logger.LoggerTest_1$TCPSocketServer.run(LoggerTest_1.java:72)

      The reason is:
      At the Startup is no socket server available, therefore a dummy ByteArrayOutputStream is created.
      See TCPSocketManager:230
      After that, the Header of the layout (Object stream header) is written to the Dummy ByteArrayOutputStream.
      See AbstractOutputStreamAppender:62

      If the Reconnector-Thread succeeds, the Dummy ByteArrayOutputStream is changed to the OutputStream from the socket.
      See TCPSocketManager:175
      But after this action the object stream header is not written again!

        Issue Links


          Ralph Goers created issue -
          Ralph Goers added a comment -

          Fixed in revision 1460497. Please verify and close.

          Ralph Goers added a comment - Fixed in revision 1460497. Please verify and close.
          Ralph Goers made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Ralph Goers [ ralph.goers@dslextreme.com ]
          Fix Version/s 2.0-beta5 [ 12323970 ]
          Resolution Fixed [ 1 ]
          Ralph Goers made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Melvin Du made changes -
          Link This issue is related to LOG4J2-1195 [ LOG4J2-1195 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          1d 2h 12m 1 Ralph Goers 25/Mar/13 00:57
          Resolved Resolved Closed Closed
          34d 5h 11m 1 Ralph Goers 28/Apr/13 06:08


            • Assignee:
              Ralph Goers
              Ralph Goers
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: