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); }
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access