java.util.logging
Class SocketHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by java.util.logging.StreamHandler
          extended by java.util.logging.SocketHandler

public class SocketHandler
extends StreamHandler

A SocketHandler publishes log records to a TCP/IP socket.

Configuration: Values of the subsequent LogManager properties are taken into consideration when a SocketHandler is initialized. If a property is not defined, or if it has an invalid value, a default is taken without an exception being thrown.


Constructor Summary
SocketHandler()
          Constructs a SocketHandler that publishes log records to a TCP/IP socket.
SocketHandler(String host, int port)
          Constructs a SocketHandler that publishes log records to a TCP/IP socket.
 
Method Summary
 void publish(LogRecord record)
          Publishes a LogRecord to the network socket, provided the record passes all tests for being loggable.
 
Methods inherited from class java.util.logging.StreamHandler
close, flush, isLoggable, setEncoding, setOutputStream
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketHandler

public SocketHandler()
              throws IOException
Constructs a SocketHandler that publishes log records to a TCP/IP socket. Tthe initial configuration is determined by the LogManager properties described above.

Throws:
IOException - if the connection to the specified network host and port cannot be established.
IllegalArgumentException - if either the java.util.logging.SocketHandler.host or java.util.logging.SocketHandler.port LogManager properties is not defined, or specifies an invalid value.

SocketHandler

public SocketHandler(String host,
                     int port)
              throws IOException
Constructs a SocketHandler that publishes log records to a TCP/IP socket. With the exception of the internet host and port, the initial configuration is determined by the LogManager properties described above.

Parameters:
host - the Internet host to which log records will be forwarded.
port - the port at the host which will accept a request for a TCP/IP connection.
Throws:
IOException - if the connection to the specified network host and port cannot be established.
IllegalArgumentException - if either host or port specify an invalid value.
Method Detail

publish

public void publish(LogRecord record)
Publishes a LogRecord to the network socket, provided the record passes all tests for being loggable. In addition, all data that may have been buffered will be forced to the network stream.

Most applications do not need to call this method directly. Instead, they will use a Logger instance, which will create LogRecords and distribute them to registered handlers.

In case of an I/O failure, the ErrorManager of this SocketHandler will be informed, but the caller of this method will not receive an exception.

Overrides:
publish in class StreamHandler
Parameters:
record - the log event to be published.