Jiří Smolík created LOG4J2-3430:
-----------------------------------
Summary: Provide a SocketAppender using NIO with a "writeTimeout"
Key: LOG4J2-3430
URL: https://issues.apache.org/jira/browse/LOG4J2-3430
Project: Log4j 2
Issue Type: Improvement
Components: Appenders
Affects Versions: 2.17.2
Reporter: Jiří Smolík
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.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)