Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1562

SocketAppender memory usage grows unbounded if it cannot connect to a server

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.2
    • 2.7
    • Appenders
    • None

    Description

      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..."

      Attachments

        Activity

          People

            ggregory Gary D. Gregory
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: