socketsconnectionlog4cplus

Log4cplus- How often does SocketAppender opens and closes the socket


I want to use Log4cplus SocketAppender to open TCP socket to a remote server and send events (log messages) to that server.

Since my application has quite a lot of log messages to send, I wish to know -

How often does the SocketAppender opens and closes connections to the remote server? does it occur on every single message that is sent? or in other frequency?

I want to prevent a state of connection "exhaustion" between the log messages sender and the remote server in case of high frequency of log messages sent.

Does the SocketAppender prevent this from occurring?


Solution

  • The connection is dropped when the close method is called , the following is copied from the documentation

    https://log4cplus.sourceforge.io/docs/html/classlog4cplus_1_1SocketAppender.html

    virtual void close () Release any resources allocated within the appender such as file handles, network connections, etc. More...