java.lang.Object | ||
↳ | org.apache.log4j.AppenderSkeleton | |
↳ | org.apache.log4j.net.SocketAppender |
Sends LoggingEvent
objects to a remote a log server,
usually a SocketNode
.
The SocketAppender has the following properties:
SocketNode
, remote 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 by
the client.
LoggingEvent
object to the server side.
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 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 close()
the SocketAppender
either explicitly or by
calling the shutdown()
method
before exiting the application.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | DEFAULT_PORT | The default port number of remote logging server (4560). | |||||||||
String | ZONE | The MulticastDNS zone advertised by a SocketAppender |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.log4j.AppenderSkeleton
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Connects to remote server at
address and port . | |||||||||||
Connects to remote server at
host and port . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Connect to the specified RemoteHost and Port.
| |||||||||||
Subclasses of
AppenderSkeleton should implement this
method to perform actual logging. | |||||||||||
Drop the connection to the remote host and release the underlying
connector thread if it has been created
| |||||||||||
Close this appender.
| |||||||||||
Returns value of the Application option.
| |||||||||||
Returns value of the LocationInfo option.
| |||||||||||
Returns value of the Port option.
| |||||||||||
Returns value of the ReconnectionDelay option.
| |||||||||||
Returns value of the RemoteHost option.
| |||||||||||
The SocketAppender does not use a layout.
| |||||||||||
The App option takes a string value which should be the name of the
application getting logged.
| |||||||||||
The LocationInfo option takes a boolean value.
| |||||||||||
The Port option takes a positive integer representing
the port where the server is waiting for connections.
| |||||||||||
The ReconnectionDelay option takes a positive integer
representing the number of milliseconds to wait between each
failed connection attempt to the server.
| |||||||||||
The RemoteHost option takes a string value which should be
the host name of the server where a
SocketNode is
running. |
[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 default port number of remote logging server (4560).
The MulticastDNS zone advertised by a SocketAppender
Connects to remote server at address
and port
.
Connects to remote server at host
and port
.
Connect to the specified RemoteHost and Port.
Subclasses of AppenderSkeleton
should implement this
method to perform actual logging. See also AppenderSkeleton.doAppend
method.
Drop the connection to the remote host and release the underlying connector thread if it has been created
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 LocationInfo option.
Returns value of the Port option.
Returns value of the ReconnectionDelay option.
Returns value of the RemoteHost option.
The SocketAppender 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 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.
The ReconnectionDelay option takes a positive integer representing the number of milliseconds to wait between each failed connection attempt to the server. The default value of this option is 30000 which corresponds to 30 seconds.
Setting this option to zero turns off reconnection capability.
The RemoteHost option takes a string value which should be
the host name of the server where a SocketNode
is
running.