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

Provide a SocketAppender using NIO with a "writeTimeout"

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.17.2
    • None
    • Appenders
    • None

    Description

      The existing SocketAppender is configurable to the maximum extent allowed by Socket, but none of the configuration options are capable of limiting execution time of the following write operation:

      https://github.com/apache/logging-log4j2/blob/e2ee2f4dd9327eb1841023c3269ba12f5673e694/log4j-core/src/main/java/org/apache/logging/log4j/core/net/TcpSocketManager.java#L253

      When the network or server is congested, the write operation may be blocked for a long time and because it is executed within a synchronized block, all other threads will wait for a lock, which causes at least a partial DoS of the calling application for as long as the congestion continues.

      As explained by rgoers  here:
      https://issues.apache.org/jira/browse/LOG4J2-3425

      the solution is using Java NIO.

      Besides the usual Socket configuration options, I also propose a "writeTimeout" option which would allow to control maximum execution time of write operations. By default, the timeout may be disabled (value of -1 or 0). When the timeout elapses, Log4j2 should probably throw a runtime exception, which can be caught and dealt with by the calling code.

      See the related ticket for more information.

      Attachments

        Activity

          People

            Unassigned Unassigned
            SkyCrawl Jiří Smolík
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: