fedora.logging
Class SimpleXMLFormatter

java.lang.Object
  extended byjava.util.logging.Formatter
      extended byfedora.logging.SimpleXMLFormatter

public class SimpleXMLFormatter
extends java.util.logging.Formatter

Description: Formater to turn a LogRecord into a simple XML format.

This differs from XMLFormatter in that it doesn't save information about sequence, logger, class, or method, and the time of the error is given only in milliseconds since the epoch. It also uses the name of the log level instead of a record element, and (if desired) will parse the messages if they start with [...], and use the inner text as a 'mid', or message id, and the remaining text for the text of the message (until non-whitespace after ]). SimpleXMLFormatter does not handle keys and params for resource bundles -- when using this class, you buy into the strategy of pre-localizing your messages, and providing a key in the message itself (before the ']' character), if wanted.

Default encoding is the string representing the encoding of the output XML *if* the handler doesn't identify it's own encoding. It is not a flag for saying what kind of output you want!

Like XMLFormatter, this can be used with arbitrary character encodings.

Version:
$id$
Author:
cwilper@cs.cornell.edu

Constructor Summary
SimpleXMLFormatter(boolean logMids, java.lang.String defaultEncoding)
          Constructs a SimpleXMLFormatter.
 
Method Summary
 java.lang.String format(java.util.logging.LogRecord record)
          Gets a formatted String for the given LogRecord.
 java.lang.String getHead(java.util.logging.Handler h)
          Gets the header string for a set of XML formatted records.
 java.lang.String getTail(java.util.logging.Handler h)
          Gets the tail string for a set of XML formatted records.
 
Methods inherited from class java.util.logging.Formatter
formatMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleXMLFormatter

public SimpleXMLFormatter(boolean logMids,
                          java.lang.String defaultEncoding)
Constructs a SimpleXMLFormatter.

Parameters:
logMids - Whether or not to log message ids.
defaultEncoding - The default encoding string to use for the XML if the handler doesn't define one.
Method Detail

format

public java.lang.String format(java.util.logging.LogRecord record)
Gets a formatted String for the given LogRecord.

Parameters:
record - The record to be formatted.
Returns:
A formatted log record.

getHead

public java.lang.String getHead(java.util.logging.Handler h)
Gets the header string for a set of XML formatted records.

Parameters:
h - The target handler.
Returns:
header string

getTail

public java.lang.String getTail(java.util.logging.Handler h)
Gets the tail string for a set of XML formatted records.

Parameters:
h - The target handler.
Returns:
tail string