Most visited

Recently visited

Added in API level 1

SocketHandler

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后刷新。

Summary

Public constructors

SocketHandler()

创建一个 SocketHandler ,仅使用 LogManager属性(或其默认值)。

SocketHandler(String host, int port)

使用指定的主机和端口构建 SocketHandler

Public methods

void close()

关闭这个输出流。

void publish(LogRecord record)

格式并发布 LogRecord

Inherited methods

From class java.util.logging.StreamHandler
From class java.util.logging.Handler
From class java.lang.Object

Public constructors

SocketHandler

Added in API level 1
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

Added in API level 1
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.

Public methods

close

Added in API level 1
void close ()

关闭这个输出流。

Throws
SecurityException if a security manager exists and if the caller does not have LoggingPermission("control").

publish

Added in API level 1
void publish (LogRecord record)

格式并发布 LogRecord

Parameters
record LogRecord: description of the log event. A null record is silently ignored and is not published

Hooray!