public class SocketHandler extends StreamHandler
This handler reads the following properties from the log manager to initialize itself:
Level.ALL
if this property is not found or has an invalid
value.
null
if this
property is not found or has an invalid value.
java.util.logging.XMLFormatter
if this property is not found or has
an invalid value.
null
if this
property is not found or has an invalid value.
This handler buffers the outgoing messages, but flushes each time a log record has been published.
This class is not thread-safe.
Constructor and Description |
---|
SocketHandler()
Constructs a
SocketHandler object using the properties read by
the log manager, including the host name and port number. |
SocketHandler(String host,
int port)
Constructs a
SocketHandler object using the specified host name
and port number together with other properties read by the log manager. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this handler.
|
void |
publish(LogRecord record)
Logs a record if necessary.
|
flush, isLoggable, setEncoding, setOutputStream
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
public SocketHandler() throws IOException
SocketHandler
object using the properties read by
the log manager, including the host name and port number. Default
formatting uses the XMLFormatter class and level is set to ALL.IOException
- if failed to connect to the specified host and port.IllegalArgumentException
- if the host name or port number is illegal.public SocketHandler(String host, int port) throws IOException
SocketHandler
object using the specified host name
and port number together with other properties read by the log manager.
Default formatting uses the XMLFormatter class and level is set to ALL.host
- the host nameport
- the port numberIOException
- if failed to connect to the specified host and port.IllegalArgumentException
- if the host name or port number is illegal.public void close()
close
in class StreamHandler
public void publish(LogRecord record)
publish
in class StreamHandler
record
- the log record to be logged.