Name

SocketHandler

Synopsis

This Handler subclass formats LogRecord objects and outputs the resulting strings to a network socket. When you create a SocketHandler, you can pass the hostname and port of the socket to the constructor or you can rely on system-wide defaults obtained with LogManager.getProperty( ). SocketHandler also uses LogManager.getProperty( ) to obtain initial values for the properties inherited from Handler. The table below lists these properties, as well as the host and port arguments, the value passed to getProperty( ), and the default value used if getProperty( ) returns null. See Handler for further details.

Handler property

LogManager property name

Default

level

java.util.logging.SocketHandler.level

Level.ALL

filter

java.util.logging.SocketHandler.filter

null

formatter

java.util.logging.SocketHandler.formatter

XMLFormatter

encoding

java.util.logging.SocketHandler.encoding

platform default

hostname

java.util.logging.SocketHandler.host

no default

port

java.util.logging.SocketHandler.port

no default

java.util.logging.SocketHandler

Figure 16-121. java.util.logging.SocketHandler

public class SocketHandler extends StreamHandler {
// Public Constructors
     public SocketHandler( ) throws java.io.IOException;  
     public SocketHandler(String host, int port) throws java.io.IOException;  
// Public Methods Overriding StreamHandler
     public void close( ) throws SecurityException;                 synchronized

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.