# XMLFormatter

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/java/util/logging/XMLFormatter#pubctors)\|[Methods](https://developer.android.com/reference/java/util/logging/XMLFormatter#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/logging/XMLFormatter#inhmethods)  

# XMLFormatter

`
public


class
XMLFormatter
`  
`


``

extends `[Formatter](https://developer.android.com/reference/java/util/logging/Formatter)`


``


`

|---|---|--------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.util.logging.Formatter](https://developer.android.com/reference/java/util/logging/Formatter) ||
|   | ↳ | java.util.logging.XMLFormatter |

<br />

*** ** * ** ***

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.

## Summary

|                                             ### Public constructors                                              ||
|---------------------------------------------------------------------------------------------------------------|---|
| ` `[XMLFormatter](https://developer.android.com/reference/java/util/logging/XMLFormatter#XMLFormatter())`() ` |

|                                                                                                                                                                ### Public methods                                                                                                                                                                ||
|-----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[format](https://developer.android.com/reference/java/util/logging/XMLFormatter#format(java.util.logging.LogRecord))`(`[LogRecord](https://developer.android.com/reference/java/util/logging/LogRecord)` record) ` Format the given message to XML.                    |
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[getHead](https://developer.android.com/reference/java/util/logging/XMLFormatter#getHead(java.util.logging.Handler))`(`[Handler](https://developer.android.com/reference/java/util/logging/Handler)` h) ` Return the header string for a set of XML formatted records. |
| ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[getTail](https://developer.android.com/reference/java/util/logging/XMLFormatter#getTail(java.util.logging.Handler))`(`[Handler](https://developer.android.com/reference/java/util/logging/Handler)` h) ` Return the tail string for a set of XML formatted records.   |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.util.logging.Formatter](https://developer.android.com/reference/java/util/logging/Formatter)` ` |--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[format](https://developer.android.com/reference/java/util/logging/Formatter#format(java.util.logging.LogRecord))`(`[LogRecord](https://developer.android.com/reference/java/util/logging/LogRecord)` record) ` Format the given log record and return the formatted string.            | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[formatMessage](https://developer.android.com/reference/java/util/logging/Formatter#formatMessage(java.util.logging.LogRecord))`(`[LogRecord](https://developer.android.com/reference/java/util/logging/LogRecord)` record) ` Localize and format the message string from a log record. | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[getHead](https://developer.android.com/reference/java/util/logging/Formatter#getHead(java.util.logging.Handler))`(`[Handler](https://developer.android.com/reference/java/util/logging/Handler)` h) ` Return the header string for a set of formatted records.                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[getTail](https://developer.android.com/reference/java/util/logging/Formatter#getTail(java.util.logging.Handler))`(`[Handler](https://developer.android.com/reference/java/util/logging/Handler)` h) ` Return the tail string for a set of formatted records.                           | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### XMLFormatter

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public XMLFormatter ()
```

<br />

<br />

## Public methods

### format

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String format (LogRecord record)
```

Format the given message to XML.

This method can be overridden in a subclass. It is recommended to use the[Formatter.formatMessage](https://developer.android.com/reference/java/util/logging/Formatter#formatMessage(java.util.logging.LogRecord))convenience method to localize and format the message field.

<br />

|                          Parameters                           ||
|----------|-----------------------------------------------------|
| `record` | `LogRecord`: the log record to be formatted. <br /> |

|                                              Returns                                              ||
|--------------------------------------------------------------------|-------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a formatted log record <br /> |

### getHead

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getHead (Handler h)
```

Return the header string for a set of XML formatted records.

<br />

|                       Parameters                        ||
|-----|----------------------------------------------------|
| `h` | `Handler`: The target handler (can be null) <br /> |

|                                            Returns                                            ||
|--------------------------------------------------------------------|---------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a valid XML string <br /> |

### getTail

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getTail (Handler h)
```

Return the tail string for a set of XML formatted records.

<br />

|                       Parameters                        ||
|-----|----------------------------------------------------|
| `h` | `Handler`: The target handler (can be null) <br /> |

|                                            Returns                                            ||
|--------------------------------------------------------------------|---------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a valid XML string <br /> |