public abstract class Formatter extends Object
通常每个日志处理程序将有一个格式化程序与它相关联的。格式化程序需要的日志并将其转换为一个字符串。
某些程序(如XMLFormatter)需要包裹的头部和尾部周围串一套格式化的记录。getheader和gettail的方法可以用来获得这些字符串。
Modifier | Constructor and Description |
---|---|
protected |
Formatter()
构建一个新的格式化程序。
|
public abstract String format(LogRecord record)
由此产生的格式化字符串通常包含局部的日志的消息字段的格式版本。这是推荐使用的方法formatMessage(java.util.logging.LogRecord)
方便定位和格式的报文字段。
record
-要格式化的日志记录。
public String getHead(Handler h)
这个基类返回一个空字符串,但这可能是由子类重写。
h
-目标处理器(可以为空)
public String getTail(Handler h)
这个基类返回一个空字符串,但这可能是由子类重写。
h
-目标处理器(可以为空)
public String formatMessage(LogRecord record)
消息字符串的第一局限于使用记录的resourcebundle格式字符串。(如果没有概念,或者消息的关键是找不到的,那么关键是作为字符串的格式。)格式字符串使用java.text格式。
record
含原消息日志记录
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.