Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.17.2
-
None
-
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:
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.