Log4j 1.1.3

org.apache.log4j.net
Class SocketAppender

java.lang.Object
  |
  +--org.apache.log4j.AppenderSkeleton
        |
        +--org.apache.log4j.net.SocketAppender
All Implemented Interfaces:
Appender, OptionHandler

public class SocketAppender
extends AppenderSkeleton

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

The SocketAppender has the following properties:

Since:
0.8.4
Author:
Ceki Gülcü

Field Summary
static String LOCATION_INFO_OPTION
          Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.
static String PORT_OPTION
          Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.
static String RECONNECTION_DELAY_OPTION
          Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.
static String REMOTE_HOST_OPTION
          Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.
 
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION
 
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.
 boolean getLocationInfo()
          Returns value of the LocationInfo option.
 String[] getOptionStrings()
          Deprecated. We now use JavaBeans introspection to configure components. Options strings are no longer needed.
 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 setOption(String option, String value)
          Set option to 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 is running.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REMOTE_HOST_OPTION

public static final String REMOTE_HOST_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

A string constant used in naming the option for setting the the host name of the remote server. Current value of this string constant is RemoteHost. See the setOption(java.lang.String, java.lang.String) method for the meaning of this option.

PORT_OPTION

public static final String PORT_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

A string constant used in naming the option for setting the the port to contect on the remote server. Current value of this string constant is Port. See the setOption(java.lang.String, java.lang.String) method for the meaning of this option.

LOCATION_INFO_OPTION

public static final String LOCATION_INFO_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

A string constant used in naming the option for setting the the location information flag. Current value of this string constant is LocationInfo. See the setOption(java.lang.String, java.lang.String) method for the meaning of this option.

RECONNECTION_DELAY_OPTION

public static final String RECONNECTION_DELAY_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

A string constant used in naming the option for setting the delay between each reconneciton attempt to remote server. Current value a of this string constant is ReconnectionDelay. See the setOption(java.lang.String, java.lang.String) method for the meaning of this option.
Constructor Detail

SocketAppender

public SocketAppender()

SocketAppender

public SocketAppender(InetAddress address,
                      int port)
Connects to remote server at address and port.

SocketAppender

public SocketAppender(String host,
                      int port)
Connects to remote server at host and port.
Method Detail

getOptionStrings

public String[] getOptionStrings()
Deprecated. We now use JavaBeans introspection to configure components. Options strings are no longer needed.

Retuns the option names for this component, namely the string array consisting of {REMOTE_HOST_OPTION, PORT_OPTION, LOCATION_INFO_OPTION, RECONNECTION_DELAY_OPTION} in addition to the options of its super class AppenderSkeleton.
Overrides:
getOptionStrings in class AppenderSkeleton

setOption

public void setOption(String option,
                      String value)
Deprecated. Use the setter method for the option directly instead of the generic setOption method.

Description copied from interface: OptionHandler
Set option to value.

The handling of each option depends on the OptionHandler instance. Some options may become active immediately whereas other may be activated only when OptionHandler.activateOptions() is called.

Overrides:
setOption in class AppenderSkeleton

activateOptions

public void activateOptions()
Connect to the specified RemoteHost and Port.
Overrides:
activateOptions in class AppenderSkeleton

close

public void close()
Close this appender.

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


cleanUp

public void cleanUp()
Drop the connection to the remote host and release the underlying connector thread if it has been created

append

public void append(LoggingEvent event)
Description copied from class: AppenderSkeleton
Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton.doAppend method.
Overrides:
append in class AppenderSkeleton

requiresLayout

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

setRemoteHost

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.

getRemoteHost

public String getRemoteHost()
Returns value of the RemoteHost option.

setPort

public void setPort(int port)
The Port option takes a positive integer representing the port where the server is waiting for connections.

getPort

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

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.

getLocationInfo

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

setReconnectionDelay

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.


getReconnectionDelay

public int getReconnectionDelay()
Returns value of the ReconnectionDelay option.

Log4j 1.1.3

Please notify me about new log4j releases.