org.apache.log4j.net
public class SocketAppender extends AppenderSkeleton
The SocketAppender has the following properties:
On the other hand, if the network link is up, but the server is down, the client will not be blocked when making log requests but the log events will be lost due to server unavailability.
SocketAppender
is no longer
attached to any category, it will not be garbage collected in
the presence of a connector thread. A connector thread exists
only if the connection to the server is down. To avoid this
garbage collection problem, you should {@link #close} the the
SocketAppender
explicitly. See also next item.
Long lived applications which create/destroy many
SocketAppender
instances should be aware of this
garbage collection problem. Most other applications can safely
ignore it.
SocketAppender
exits
before the SocketAppender
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 SocketAppender
either explicitly or by
calling the {@link org.apache.log4j.LogManager#shutdown} method
before exiting the application.
Since: 0.8.4
Constructor Summary | |
---|---|
SocketAppender() | |
SocketAppender(InetAddress address, int port)
Connects to remote server at address and port . | |
SocketAppender(String host, int port)
Connects to remote server at host and port . |
Method Summary | |
---|---|
void | activateOptions()
Connect to the specified RemoteHost and Port. |
void | append(LoggingEvent event) |
void | cleanUp()
Drop the connection to the remote host and release the underlying
connector thread if it has been created
|
void | close()
Close this appender.
|
boolean | getLocationInfo()
Returns value of the LocationInfo option. |
int | getPort()
Returns value of the Port option. |
int | getReconnectionDelay()
Returns value of the ReconnectionDelay option. |
String | getRemoteHost()
Returns value of the RemoteHost option. |
boolean | requiresLayout()
The SocketAppender does not use a layout. |
void | setLocationInfo(boolean locationInfo)
The LocationInfo option takes a boolean value. |
void | setPort(int port)
The Port option takes a positive integer representing
the port where the server is waiting for connections. |
void | setReconnectionDelay(int delay)
The ReconnectionDelay option takes a positive integer
representing the number of milliseconds to wait between each
failed connection attempt to the server. |
void | setRemoteHost(String host)
The RemoteHost option takes a string value which should be
the host name of the server where a {@link SocketNode} is
running.
|
address
and port
.host
and port
.This will mark the appender as closed and call then {@link #cleanUp} method.
false
.
Setting this option to zero turns off reconnection capability.