Save This Page
Home » apache-log4j-1.2.15 » org.apache » log4j » net » [javadoc | source]
org.apache.log4j.net
public class: SocketAppender [javadoc | source]
java.lang.Object
   org.apache.log4j.AppenderSkeleton
      org.apache.log4j.net.SocketAppender

All Implemented Interfaces:
    OptionHandler, Appender

Sends LoggingEvent objects to a remote a log server, usually a SocketNode .

The SocketAppender has the following properties:

Nested Class Summary:
class  SocketAppender.Connector  The Connector will reconnect when the server becomes available again. It does this by attempting to open a new connection every reconnectionDelay milliseconds.

It stops trying whenever a connection is established. It will restart to try reconnect to the server when previpously open connection is droppped. 

Field Summary
public static final  int DEFAULT_PORT    The default port number of remote logging server (4560).
    since: 1.2.15 -
 
static final  int DEFAULT_RECONNECTION_DELAY    The default reconnection delay (30000 milliseconds or 30 seconds). 
 String remoteHost    We remember host name as String in addition to the resolved InetAddress so that it can be returned via getOption(). 
 InetAddress address     
 int port     
 ObjectOutputStream oos     
 int reconnectionDelay     
 boolean locationInfo     
 int counter     
Fields inherited from org.apache.log4j.AppenderSkeleton:
layout,  name,  threshold,  errorHandler,  headFilter,  tailFilter,  closed
Constructor:
 public SocketAppender() 
 public SocketAppender(InetAddress address,
    int port) 
    Connects to remote server at address and port.
 public SocketAppender(String host,
    int port) 
    Connects to remote server at host and port.
Method from org.apache.log4j.net.SocketAppender Summary:
activateOptions,   append,   cleanUp,   close,   connect,   fireConnector,   getAddressByName,   getApplication,   getLocationInfo,   getPort,   getReconnectionDelay,   getRemoteHost,   requiresLayout,   setApplication,   setLocationInfo,   setPort,   setReconnectionDelay,   setRemoteHost
Methods from org.apache.log4j.AppenderSkeleton:
activateOptions,   addFilter,   append,   clearFilters,   doAppend,   finalize,   getErrorHandler,   getFilter,   getFirstFilter,   getLayout,   getName,   getThreshold,   isAsSevereAsThreshold,   setErrorHandler,   setLayout,   setName,   setThreshold
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.log4j.net.SocketAppender Detail:
 public  void activateOptions() 
    Connect to the specified RemoteHost and Port.
 public  void append(LoggingEvent event) 
 public  void cleanUp() 
    Drop the connection to the remote host and release the underlying connector thread if it has been created
 public synchronized  void close() 
    Close this appender.

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

  void connect(InetAddress address,
    int port) 
  void fireConnector() 
 static InetAddress getAddressByName(String host) 
 public String getApplication() 
    Returns value of the Application option.
 public boolean getLocationInfo() 
    Returns value of the LocationInfo option.
 public int getPort() 
    Returns value of the Port option.
 public int getReconnectionDelay() 
    Returns value of the ReconnectionDelay option.
 public String getRemoteHost() 
    Returns value of the RemoteHost option.
 public boolean requiresLayout() 
    The SocketAppender does not use a layout. Hence, this method returns false.
 public  void setApplication(String lapp) 
    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.
 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.
 public  void setPort(int port) 
    The Port option takes a positive integer representing the port where the server is waiting for connections.
 public  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. The default value of this option is 30000 which corresponds to 30 seconds.

    Setting this option to zero turns off reconnection capability.

 public  void setRemoteHost(String host) 
    The RemoteHost option takes a string value which should be the host name of the server where a SocketNode is running.