public class SocketHandler
extends StreamHandler
| java.lang.Object | |||
| java.util.logging.Handler | |||
| java.util.logging.StreamHandler | |||
| java.util.logging.SocketHandler | |||
简单的网络日志记录 Handler 。
LogRecords发布到网络流连接。 默认情况下, XMLFormatter类用于格式化。
配置:默认情况下,每个SocketHandler都使用以下LogManager配置属性进行初始化。 如果属性未定义(或者具有无效值),则使用指定的默认值。
输出IO流被缓冲,但是在写入每个 LogRecord后刷新。
Public constructors |
|
|---|---|
SocketHandler() 创建一个 SocketHandler ,仅使用 LogManager属性(或其默认值)。 |
|
SocketHandler(String host, int port) 使用指定的主机和端口构建 SocketHandler 。 |
|
公共方法(Public methods) |
|
|---|---|
void |
close() 关闭这个输出流。 |
void |
publish(LogRecord record) 格式并发布 LogRecord 。 |
继承方法(Inherited methods) |
|
|---|---|
java.util.logging.StreamHandler
|
|
java.util.logging.Handler
|
|
java.lang.Object
|
|
SocketHandler ()
创建一个 SocketHandler ,仅使用 LogManager属性(或其默认值)。
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if the host or port are invalid or are not specified as LogManager properties. |
IOException |
if we are unable to connect to the target host and port. |
SocketHandler (String host, int port)
使用指定的主机和端口构建SocketHandler 。 SocketHandler是基于LogManager属性(或其默认值)配置的,除了使用给定的目标主机和端口参数。 如果主机参数为空,但不为空字符串,则使用localhost。
| 参数(Parameters) | |
|---|---|
host |
String: target host. |
port |
int: target port. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if the host or port are invalid. |
IOException |
if we are unable to connect to the target host and port. |
void close ()
关闭这个输出流。
| 抛出异常(Throws) | |
|---|---|
SecurityException |
if a security manager exists and if the caller does not have LoggingPermission("control"). |
void publish (LogRecord record)
格式并发布 LogRecord 。
| 参数(Parameters) | |
|---|---|
record |
LogRecord: description of the log event. A null record is silently ignored and is not published |