Name
XMLFormatter
Synopsis
This Formatter
subclass converts a LogRecord
to an XML-formatted
string. The format( )
method returns a
<record>
element, which always contains
<date>
, <millis>
,
<sequence>
, <level>
and <message>
tags, and may also contain
<logger>
, <class>
,
<method>
, <thread>
,
<key>
, <catalog>
,
<param>
, and
<exception>
tags. See http://java.sun.com/dtd/logger.dtd for the
DTD of the output document.
The getHead( )
and getTail( )
methods are overridden to return opening and closing
<log>
and </log>
tags to surround all output <record>
tags.
Note however, that if an application terminates abnormally, the
logging facility may be unable to terminate the log file with the
closing <log>
tag.
Figure 16-123. java.util.logging.XMLFormatter
public class XMLFormatter extends java.util.logging.Formatter { // Public Constructors public XMLFormatter( ); // Public Methods Overriding Formatter public String format(LogRecord record); public String getHead(Handler h); public String getTail(Handler h); }
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.