Class XMLFormatter

java.lang.Object
java.util.logging.Formatter
java.util.logging.XMLFormatter

public class XMLFormatter
extends Formatter
Formatter to convert a LogRecord into an XML string. The DTD specified in Appendix A to the Java Logging APIs specification is used. XMLFormatter uses the output handler's encoding if it is specified, otherwise the default platform encoding is used instead. UTF-8 is the recommended encoding.
  • Constructor Details

    • XMLFormatter

      public XMLFormatter()
      Constructs a new XMLFormatter.
  • Method Details

    • format

      public String format​(LogRecord r)
      Converts a LogRecord into an XML string.
      Specified by:
      format in class Formatter
      Parameters:
      r - the log record to be formatted.
      Returns:
      the log record formatted as an XML string.
    • getHead

      public String getHead​(Handler h)
      Returns the header string for a set of log records formatted as XML strings, using the output handler's encoding if it is defined, otherwise using the default platform encoding.
      Overrides:
      getHead in class Formatter
      Parameters:
      h - the output handler, may be null.
      Returns:
      the header string for log records formatted as XML strings.
    • getTail

      public String getTail​(Handler h)
      Returns the tail string for a set of log records formatted as XML strings.
      Overrides:
      getTail in class Formatter
      Parameters:
      h - the output handler, may be null.
      Returns:
      the tail string for log records formatted as XML strings.