Acts just like {@link SocketAppender} except that instead ofconnecting to a given remote log server, SocketHubAppender
accepts connections from the remote log servers as clients. It can accept more than one connection. When a log event is received, the event is sent to the set of currently connected remote log servers. Implemented this way it does not require any update to the configuration file to send data to another remote log server. The remote log server simply connects to the host and port the SocketHubAppender
is running on.
The SocketHubAppender
does not store events such that the remote side will events that arrived after the establishment of its connection. Once connected, events arrive in order as guaranteed by the TCP protocol.
This implementation borrows heavily from the {@link SocketAppender}.
The SocketHubAppender has the following characteristics:
SocketHubAppender
does not use a layout. It ships a serialized {@link LoggingEvent} object to the remote side.SocketHubAppender
relies on the TCP protocol. Consequently, if the remote side is reachable, then log events will eventually arrive at remote client. On the other hand, if the network link is up, but the remote client is down, the client will not be blocked when making log requests but the log events will be lost due to client unavailability.
The single remote client case extends to multiple clients connections. The rate of logging will be determined by the slowest link.
The BufferSize param provides a cyclic buffer of recently appended events. As new clients attach to the SocketHubAppender, the clients also receive the buffered events.
SocketHubAppender
exits before the SocketHubAppender
is closed either explicitly or subsequent to garbage collection, then there might be untransmitted data in the pipe which might be lost. This is a common problem on Windows based systems. To avoid lost data, it is usually sufficient to {@link #close}the SocketHubAppender
either explicitly or by calling the {@link org.apache.log4j.LogManager#shutdown} method beforeexiting the application.
|
|
|
|