java.lang.Object | ||
↳ | org.apache.log4j.AppenderSkeleton | |
↳ | org.apache.log4j.net.SocketHubAppender |
Sends LoggingEvent
objects to a set of remote log servers,
usually a SocketNodes
.
Acts just like SocketAppender
except that instead of
connecting 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 SocketAppender
.
The SocketHubAppender has the following characteristics:
SocketNode
, logging is non-intrusive as
far as the log event is concerned. In other words, the event will be
logged with the same time stamp, NDC
,
location info as if it were logged locally.
SocketHubAppender
does not use a layout. It
ships a serialized 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.
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 close()
the SocketHubAppender
either explicitly or by calling
the shutdown()
method before
exiting the application.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ZONE | The MulticastDNS zone advertised by a SocketHubAppender |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.log4j.AppenderSkeleton
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Connects to remote server at
address and port . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Set up the socket server on the specified port.
| |||||||||||
Append an event to all of current connections.
| |||||||||||
Release the underlying ServerMonitor thread, and drop the connections
to all connected remote servers.
| |||||||||||
Close this appender.
| |||||||||||
Returns value of the Application option.
| |||||||||||
Returns value of the bufferSize option.
| |||||||||||
Returns value of the LocationInfo option.
| |||||||||||
Returns value of the Port option.
| |||||||||||
The SocketHubAppender does not use a layout.
| |||||||||||
The App option takes a string value which should be the name of the application getting logged.
| |||||||||||
The BufferSize option takes a positive integer representing the number of events this appender will buffer and send to newly connected
clients.
| |||||||||||
The LocationInfo option takes a boolean value.
| |||||||||||
The Port option takes a positive integer representing
the port where the server is waiting for connections.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a server socket to accept connections.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.log4j.AppenderSkeleton
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.apache.log4j.Appender
| |||||||||||
From interface
org.apache.log4j.spi.OptionHandler
|
The MulticastDNS zone advertised by a SocketHubAppender
Connects to remote server at address
and port
.
Set up the socket server on the specified port.
Release the underlying ServerMonitor thread, and drop the connections to all connected remote servers.
Close this appender.
This will mark the appender as closed and
call then cleanUp()
method.
Returns value of the Application option.
Returns value of the bufferSize option.
Returns value of the LocationInfo option.
Returns value of the Port option.
The SocketHubAppender does not use a layout. Hence, this method returns
false
.
The App option takes a string value which should be the name of the application getting logged. If property was already set (via system property), don't set here.
The BufferSize option takes a positive integer representing the number of events this appender will buffer and send to newly connected clients.
The LocationInfo option takes a boolean value. If true, the information sent to the remote host will include location information. By default no location information is sent to the server.
The Port option takes a positive integer representing the port where the server is waiting for connections.
Creates a server socket to accept connections.
socketPort | port on which the socket should listen, may be zero. |
---|
IOException | IO error when opening the socket. |
---|