public abstract class Handler extends Object
一个Handler可以通过做一个setLevel(Level.OFF)残疾人可以重新用一个适当的水平做一个setLevel启用。
Handler类通常使用LogManager属性设置为Handler的Filter,Formatter默认值,并Level。看到每个具体的Handler类具体的资料。
Modifier | Constructor and Description |
---|---|
protected |
Handler()
默认构造函数。
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
关闭
Handler和释放所有相关资源。
|
abstract void |
flush()
刷新任何缓冲输出。
|
String |
getEncoding()
返回这个
Handler字符编码。
|
ErrorManager |
getErrorManager()
检索此汉德勒中所定义的错误。
|
Filter |
getFilter()
获取当前的这
Handler
Filter。
|
Formatter |
getFormatter()
返回这个
Handler的
Formatter。
|
Level |
getLevel()
把日志级别指定的消息将通过这
Handler登录。
|
boolean |
isLoggable(LogRecord record)
看看这
Handler实际上记录了
LogRecord。
|
abstract void |
publish(LogRecord record)
发布
LogRecord。
|
protected void |
reportError(String msg, 异常 ex, int code)
保护便利的方法对汉德勒的报告中所定义的错误错误。
|
void |
setEncoding(String encoding)
这
Handler集编码使用的字符。
|
void |
setErrorManager(ErrorManager em)
这一定义中所定义的错误汉德勒。
|
void |
setFilter(Filter newFilter)
设置一个
Filter控制这
Handler输出。
|
void |
setFormatter(Formatter newFormatter)
设置一个
Formatter。
|
void |
setLevel(Level newLevel)
设置日志级别指定的消息会被这种
Handler登录。
|
protected Handler()
public abstract void publish(LogRecord record)
测井进行请求的开始Logger对象,初始化的LogRecord转发这里。
的Handler负责格式化的消息,如果有必要。格式化应包括本地化。
record
-日志事件描述。一个空记录被忽略,并没有被发布
public abstract void flush()
public abstract void close() throws SecurityException
Close方法将执行flush然后关闭Handler。关闭后被称为这Handler应该不再使用。方法调用可能被忽略或可能抛出运行时异常。
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
public void setFormatter(Formatter newFormatter) throws SecurityException
一些Handlers不得使用Formatters,在这种情况下,Formatter会记得,但没有用。
newFormatter
-
Formatter使用(不得为空)
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
public Formatter getFormatter()
public void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException
编码前应设置任何LogRecords写入Handler。
encoding
-支持的字符编码名称。可以为空,以指示默认的平台编码。
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
UnsupportedEncodingException
-如果指定的编码不支持。
public String getEncoding()
public void setFilter(Filter newFilter) throws SecurityException
每个电话publish的Handler称这种Filter(如果它是非空)检查LogRecord应发表或丢弃。
newFilter
-
Filter对象(可能为空)
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
public Filter getFilter()
public void setErrorManager(ErrorManager em)
中所定义的错误的“错误”的方法会被调用,如果发生任何错误,而使用此处理程序。
em
-新中所定义的错误
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
public ErrorManager getErrorManager()
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
protected void reportError(String msg, 异常 ex, int code)
msg
-一个描述性的字符串(可能为空)
ex
-例外(可能为空)
code
定义中所定义的错误代码中的错误
public void setLevel(Level newLevel) throws SecurityException
其目的是让开发商把大量的记录,但限制发送到一定的Handlers消息。
newLevel
-日志级别的新价值
SecurityException
-如果存在一个安全管理,如果对方没有
LoggingPermission("control")。
public Level getLevel()
public boolean isLoggable(LogRecord record)
该方法检查是否有适当的Level LogRecord是否满足任何Filter。它也可能会让其他Handler具体检查可能阻止一个处理程序从测井LogRecord。它将在LogRecord为空返回false。
record
-
LogRecord
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.