XMLFormatter
Stay organized with collections
Save and categorize content based on your preferences.
Format a LogRecord into a standard XML format.
The DTD specification is provided as Appendix A to the
Java Logging APIs specification.
The XMLFormatter can be used with arbitrary character encodings,
but it is recommended that it normally be used with UTF-8. The
character encoding can be set on the output Handler.
Public Constructor Summary
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long timeout)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
Public Methods
Format the given message to XML.
This method can be overridden in a subclass.
It is recommended to use the Formatter.formatMessage(LogRecord)
convenience method to localize and format the message field.
Parameters
record |
the log record to be formatted. |
Return the header string for a set of XML formatted records.
Parameters
h |
The target handler (can be null) |
Return the tail string for a set of XML formatted records.
Parameters
h |
The target handler (can be null) |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eXMLFormatter\u003c/code\u003e formats LogRecord data into a standard XML format as defined in the Java Logging APIs specification.\u003c/p\u003e\n"],["\u003cp\u003eIt is recommended to use UTF-8 encoding with \u003ccode\u003eXMLFormatter\u003c/code\u003e, though other character encodings are supported.\u003c/p\u003e\n"],["\u003cp\u003eThis class provides methods to format log records (\u003ccode\u003eformat\u003c/code\u003e), get the header for a set of XML records (\u003ccode\u003egetHead\u003c/code\u003e), and get the tail for a set of XML records (\u003ccode\u003egetTail\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eXMLFormatter\u003c/code\u003e inherits methods from \u003ccode\u003eFormatter\u003c/code\u003e for general formatting and localization functionalities.\u003c/p\u003e\n"]]],[],null,["# XMLFormatter\n\npublic class **XMLFormatter** extends [Formatter](../../../../reference/java/util/logging/Formatter.html) \nFormat a LogRecord into a standard XML format.\n\n\nThe DTD specification is provided as Appendix A to the\nJava Logging APIs specification.\n\n\nThe XMLFormatter can be used with arbitrary character encodings,\nbut it is recommended that it normally be used with UTF-8. The\ncharacter encoding can be set on the output Handler. \n\n### Public Constructor Summary\n\n|---|--------------------------------------------------------------------------------------------|\n| | [XMLFormatter](../../../../reference/java/util/logging/XMLFormatter.html#XMLFormatter())() |\n\n### Public Method Summary\n\n|-------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [String](../../../../reference/java/lang/String.html) | [format](../../../../reference/java/util/logging/XMLFormatter.html#format(java.util.logging.LogRecord))([LogRecord](../../../../reference/java/util/logging/LogRecord.html) record) Format the given message to XML. |\n| [String](../../../../reference/java/lang/String.html) | [getHead](../../../../reference/java/util/logging/XMLFormatter.html#getHead(java.util.logging.Handler))([Handler](../../../../reference/java/util/logging/Handler.html) h) Return the header string for a set of XML formatted records. |\n| [String](../../../../reference/java/lang/String.html) | [getTail](../../../../reference/java/util/logging/XMLFormatter.html#getTail(java.util.logging.Handler))([Handler](../../../../reference/java/util/logging/Handler.html) h) Return the tail string for a set of XML formatted records. |\n\n### Inherited Method Summary\n\nFrom class [java.util.logging.Formatter](../../../../reference/java/util/logging/Formatter.html) \n\n|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [String](../../../../reference/java/lang/String.html) | [format](../../../../reference/java/util/logging/Formatter.html#format(java.util.logging.LogRecord))([LogRecord](../../../../reference/java/util/logging/LogRecord.html) record) Format the given log record and return the formatted string. |\n| synchronized [String](../../../../reference/java/lang/String.html) | [formatMessage](../../../../reference/java/util/logging/Formatter.html#formatMessage(java.util.logging.LogRecord))([LogRecord](../../../../reference/java/util/logging/LogRecord.html) record) Localize and format the message string from a log record. |\n| [String](../../../../reference/java/lang/String.html) | [getHead](../../../../reference/java/util/logging/Formatter.html#getHead(java.util.logging.Handler))([Handler](../../../../reference/java/util/logging/Handler.html) h) Return the header string for a set of formatted records. |\n| [String](../../../../reference/java/lang/String.html) | [getTail](../../../../reference/java/util/logging/Formatter.html#getTail(java.util.logging.Handler))([Handler](../../../../reference/java/util/logging/Handler.html) h) Return the tail string for a set of formatted records. |\n\nFrom class [java.lang.Object](../../../../reference/java/lang/Object.html) \n\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../reference/java/lang/Object.html) | [clone](../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| final void | [notifyAll](../../../../reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |\n| [String](../../../../reference/java/lang/String.html) | [toString](../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nPublic Constructors\n-------------------\n\n#### public\n**XMLFormatter**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public [String](../../../../reference/java/lang/String.html)\n**format**\n([LogRecord](../../../../reference/java/util/logging/LogRecord.html) record)\n\nFormat the given message to XML.\n\n\nThis method can be overridden in a subclass.\nIt is recommended to use the [Formatter.formatMessage(LogRecord)](../../../../reference/java/util/logging/Formatter.html#formatMessage(java.util.logging.LogRecord))\nconvenience method to localize and format the message field. \n\n##### Parameters\n\n| record | the log record to be formatted. |\n|--------|---------------------------------|\n\n##### Returns\n\n- a formatted log record \n\n#### public [String](../../../../reference/java/lang/String.html)\n**getHead**\n([Handler](../../../../reference/java/util/logging/Handler.html) h)\n\nReturn the header string for a set of XML formatted records. \n\n##### Parameters\n\n| h | The target handler (can be null) |\n|---|----------------------------------|\n\n##### Returns\n\n- a valid XML string \n\n#### public [String](../../../../reference/java/lang/String.html)\n**getTail**\n([Handler](../../../../reference/java/util/logging/Handler.html) h)\n\nReturn the tail string for a set of XML formatted records. \n\n##### Parameters\n\n| h | The target handler (can be null) |\n|---|----------------------------------|\n\n##### Returns\n\n- a valid XML string"]]