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
Caused by: java.io.StreamCorruptedException: invalid stream header: 7372003E
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
The reason is:
At the Startup is no socket server available, therefore a dummy ByteArrayOutputStream is created.
After that, the Header of the layout (Object stream header) is written to the Dummy ByteArrayOutputStream.
If the Reconnector-Thread succeeds, the Dummy ByteArrayOutputStream is changed to the OutputStream from the socket.
But after this action the object stream header is not written again!
- is related to
LOG4J2-3518 SocketAppender don't send headers on reconnect
LOG4J2-1195 KafkaAppender doesn't work with SerializedLayout