|
Log4j 1.3alpha-7 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.log4j.spi.ComponentBase
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
LogManager.shutdown()
method before exiting the
application.
Field Summary | |
static int |
DEFAULT_PORT
The default port number of remote logging server (4560). |
Fields inherited from class org.apache.log4j.AppenderSkeleton |
active, closed, headFilter, layout, name, tailFilter, threshold |
Fields inherited from class org.apache.log4j.spi.ComponentBase |
repository |
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)
Subclasses of AppenderSkeleton should implement this method
to perform actual logging. |
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. |
String |
getApplication()
Returns value of the Application option. |
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. |
void |
setApplication(String lapp)
The App option takes a string value which should be the name of the application getting logged. |
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 SocketNode or a
SocketReceiver is running. |
Methods inherited from class org.apache.log4j.AppenderSkeleton |
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isActive, isAsSevereAsThreshold, isClosed, setErrorHandler, setLayout, setName, setThreshold |
Methods inherited from class org.apache.log4j.spi.ComponentBase |
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.log4j.Appender |
setLoggerRepository |
Field Detail |
public static final int DEFAULT_PORT
Constructor Detail |
public SocketAppender()
public SocketAppender(InetAddress address, int port)
address
and port
.
public SocketAppender(String host, int port)
host
and port
.
Method Detail |
public void activateOptions()
activateOptions
in interface OptionHandler
activateOptions
in class AppenderSkeleton
public void close()
This will mark the appender as closed and call then cleanUp()
method.
public void cleanUp()
public void append(LoggingEvent event)
AppenderSkeleton
AppenderSkeleton
should implement this method
to perform actual logging. See also AppenderSkeleton.doAppend
method.
append
in class AppenderSkeleton
public void setRemoteHost(String host)
SocketNode
or a
SocketReceiver
is running.
public String getRemoteHost()
public void setPort(int port)
public int getPort()
public void setLocationInfo(boolean locationInfo)
public boolean getLocationInfo()
public void setApplication(String lapp)
public String getApplication()
public void setReconnectionDelay(int delay)
Setting this option to zero turns off reconnection capability.
public int getReconnectionDelay()
|
Log4j 1.3alpha-7 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |