Gary Gregory created LOG4J2-1562:
------------------------------------

             Summary: SocketAppender memoey usage grows unbounded if it cannot 
connect to a server
                 Key: LOG4J2-1562
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1562
             Project: Log4j 2
          Issue Type: Bug
          Components: Appenders
    Affects Versions: 2.6.2
            Reporter: Gary Gregory
            Assignee: Gary Gregory


SocketAppender memoey usage grows unbounded if it cannot connect to a server.

The socket appender uses a ByteArrayOutputStream as its data sink if a socket 
cannot be opened to the server. The appender then tries to reconnect to this 
server and then overwrites the output stream. The data in the 
ByteArrayOutputStream is lost. The problem is that if the server is never 
there, the ByteArrayOutputStream will keep on accumulating log events until the 
JVM runs out of memory.

The proposed solution is to replace using a ByteArrayOutputStream with a 
NullOutputStream.

As Remko remarks on the dev ML: "Actually supporting message buffering until 
reconnect properly is not going to be trivial. (Wouldn't a spool file be better 
than a memory buffer? Bounded or unbounded? What to do if we discover an unsent 
spool file at startup? How do we handle disconnects while sending events from 
the spool file? What about log4j shutdown while sending a large spool file? Or 
process crashes?) We're entering Kafka-like territory here..."




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to