Download Wiley Professional Java JDK 6 Edition

Transcript
Chapter 1: Key Java Language Features and Libraries
getTail() methods are used to output the start and end of the XML file, the parts that aren’t repeated
for each log record but are necessary to create a valid XML file.
Example output from the XMLFormatter follows:
<?xml version=”1.0” encoding=”windows-1252” standalone=”no”?>
<!DOCTYPE log SYSTEM “logger.dtd”>
<log>
<record>
<date>2004-04-18T12:22:36</date>
<millis>1082305356235</millis>
<sequence>0</sequence>
<logger>LoggingTest</logger>
<level>INFO</level>
<class>LoggingTest</class>
<method>main</method>
<thread>10</thread>
<message>test 1</message>
</record>
<record>
<date>2004-04-18T12:22:36</date>
<millis>1082305356265</millis>
<sequence>1</sequence>
<logger>LoggingTest</logger>
<level>INFO</level>
<class>LoggingTest</class>
<method>main</method>
<thread>10</thread>
<message>test 2</message>
</record>
</log>
The XML DTD that the logging system uses is shown here:
<!-- DTD used by the java.util.logging.XMLFormatter -->
<!-- This provides an XML formatted log message. -->
<!-- The document type is “log” which consists of a sequence
of record elements -->
<!ELEMENT log (record*)>
<!-- Each logging call is described by a record element. -->
<!ELEMENT record (date, millis, sequence, logger?, level,
class?, method?, thread?, message, key?, catalog?, param*, exception?)>
<!-- Date and time when LogRecord was created in ISO 8601 format -->
<!ELEMENT date (#PCDATA)>
<!-- Time when LogRecord was created in milliseconds since
midnight January 1st, 1970, UTC. -->
<!ELEMENT millis (#PCDATA)>
<!-- Unique sequence number within source VM. -->
53