[ 
https://issues.apache.org/jira/browse/LOG4J2-2989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17260335#comment-17260335
 ] 

Yi commented on LOG4J2-2989:
----------------------------

Thank [~rgoers] and [~ggregory] for the replies.

Regarding the FailoverAppender, my understanding is that it helps to redirect 
the logs to other methods once the current Appender fails. For instance, if 
SocketAppender is the main and ConsoleAppender is for failover, once the stream 
connection breaks and cannot be re-established, the logs are redirected to the 
console output instead.

However, what we would like to achieve here is to buffer the logs, and send 
them again once the connection is able to be reconnected. There might be just a 
short outage on the other side of the stream. For instance, network issue or 
the server gets restarted etc..

My understanding is that Reconnector in TcpSocketManager tries to reconnect 
immediately. But if it cannot reconnect with the 1st retry, the current log 
event is then lost.

Would it be possible to have a buffer within the reconnector to buffer the 
bytes and resend them if possible to reconnect after a while?

Thanks in advance.

 

> Has Log4j2 a risk of losing logs for streaming towards a remote server when 
> it cannot re-establish a connection towards the server?
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-2989
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2989
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Appenders
>    Affects Versions: 2.13.3
>            Reporter: Yi
>            Priority: Major
>
> Hi,
> Currently we are trying log4j2 to stream logs towards the remote server with 
> SocketAppender.
> I am checking the source code of TcpSocketManager and its inner class 
> Reconnector.
> protected void TcpSocketManager:write(...)
> In the above function, once the manager cannot write to the socket, it use 
> the reconnector to reconnect synchronizely. If it succeeds, it sends the 
> bytes again and everything is fine.
> However, if it fails, the reconnector is going to start a seperate thread and 
> wait for a configurable time to reconnect. But the current method throws an 
> exception instead and the bytes/Log event is then lost due to broken 
> connection.
> Is my understanding correct? If so, can it be improved?
> Thanks in advance. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to