org.apache.log4j.net

Class SocketHubAppender

public class SocketHubAppender extends AppenderSkeleton

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:

Author: Mark Womack

Constructor Summary
SocketHubAppender()
SocketHubAppender(int _port)
Connects to remote server at address and port.
Method Summary
voidactivateOptions()
Set up the socket server on the specified port.
voidappend(LoggingEvent event)
Append an event to all of current connections.
voidcleanUp()
Release the underlying ServerMonitor thread, and drop the connections to all connected remote servers.
voidclose()
Close this appender.
booleangetLocationInfo()
Returns value of the LocationInfo option.
intgetPort()
Returns value of the Port option.
booleanrequiresLayout()
The SocketHubAppender does not use a layout.
voidsetLocationInfo(boolean _locationInfo)
The LocationInfo option takes a boolean value.
voidsetPort(int _port)
The Port option takes a positive integer representing the port where the server is waiting for connections.

Constructor Detail

SocketHubAppender

public SocketHubAppender()

SocketHubAppender

public SocketHubAppender(int _port)
Connects to remote server at address and port.

Method Detail

activateOptions

public void activateOptions()
Set up the socket server on the specified port.

append

public void append(LoggingEvent event)
Append an event to all of current connections.

cleanUp

public void cleanUp()
Release the underlying ServerMonitor thread, and drop the connections to all connected remote servers.

close

public void close()
Close this appender.

This will mark the appender as closed and call then SocketHubAppender method.

getLocationInfo

public boolean getLocationInfo()
Returns value of the LocationInfo option.

getPort

public int getPort()
Returns value of the Port option.

requiresLayout

public boolean requiresLayout()
The SocketHubAppender does not use a layout. Hence, this method returns false.

setLocationInfo

public void setLocationInfo(boolean _locationInfo)
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.

setPort

public void setPort(int _port)
The Port option takes a positive integer representing the port where the server is waiting for connections.
Copyright 2000-2005 Apache Software Foundation.