Package org.jboss.logmanager.formatters

## Class XmlFormatter

- java.lang.Object
- - java.util.logging.Formatter
  - - org.jboss.logmanager.ExtFormatter
    - - org.jboss.logmanager.formatters.StructuredFormatter
      - - org.jboss.logmanager.formatters.XmlFormatter

    public class XmlFormatter
    extends StructuredFormatter

A formatter that outputs the record in XML format.

The details include;

- `source class name`
- `source file name`
- `source method name`
- `source line number`

Author:
  James R. Perkins

### Nested Class Summary

### Nested classes/interfaces inherited from class org.jboss.logmanager.formatters.StructuredFormatter

`StructuredFormatter.ExceptionOutputType, StructuredFormatter.Generator, StructuredFormatter.Key`

### Field Summary

Fields
`static java.lang.String` `DEFAULT_NAMESPACE`

### Constructor Summary

Constructors
`XmlFormatter()` Creates a new XML formatter.
`XmlFormatter​(java.lang.String keyOverrides)` Creates a new XML formatter.
`XmlFormatter​(java.util.Map<StructuredFormatter.Key,java.lang.String> keyOverrides)` Creates a new XML formatter.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected StructuredFormatter.Generator` `createGenerator​(java.io.Writer writer)` Creates the generator used to create the structured data.
`java.lang.String` `getNamespaceUri()` Returns the namespace URI used for each record if `isPrintNamespace()` is `true`.
`boolean` `isPrettyPrint()` Indicates whether or not pretty printing is enabled.
`boolean` `isPrintNamespace()` Indicates whether or not the name space should be written on the `<record/>`.
`void` `setNamespaceUri​(java.lang.String namespaceUri)` Sets the namespace URI used for each record if `isPrintNamespace()` is `true`.
`void` `setPrettyPrint​(boolean prettyPrint)` Turns on or off pretty printing.
`void` `setPrintNamespace​(boolean printNamespace)` Turns on or off the printing of the namespace for each `<record/>`.

### Methods inherited from class org.jboss.logmanager.ExtFormatter

`format`

### Methods inherited from class java.util.logging.Formatter

`formatMessage, getHead, getTail`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from class org.jboss.logmanager.formatters.StructuredFormatter

`after, before, format, getDateTimeFormatter, getExceptionOutputType, getKey, getKeyOverrides, getMetaData, getRecordDelimiter, getZoneId, isCallerCalculationRequired, isDetailedExceptionOutputType, isFormattedExceptionOutputType, isPrintDetails, setDateFormat, setExceptionOutputType, setMetaData, setPrintDetails, setRecordDelimiter, setZoneId`

### Field Detail

#### DEFAULT_NAMESPACE

    public static final java.lang.String DEFAULT_NAMESPACE

See Also:
  Constant Field Values

### Constructor Detail

#### XmlFormatter

    public XmlFormatter()

Creates a new XML formatter.

#### XmlFormatter

    public XmlFormatter​(java.lang.String keyOverrides)

Creates a new XML formatter.

If the `keyOverrides` is empty the default namespace will be used.

Parameters:
  `keyOverrides` - a string representation of a map to override keys
See Also:
  `PropertyValues.stringToEnumMap(Class, String)`

#### XmlFormatter

    public XmlFormatter​(java.util.Map<StructuredFormatter.Key,java.lang.String> keyOverrides)

Creates a new XML formatter.

If the `keyOverrides` is empty the default namespace will be used.

Parameters:
  `keyOverrides` - a map of overrides for the default keys

### Method Detail

#### isPrettyPrint

    public boolean isPrettyPrint()

Indicates whether or not pretty printing is enabled.

Returns:
  `true` if pretty printing is enabled, otherwise `false`

#### setPrettyPrint

    public void setPrettyPrint​(boolean prettyPrint)

Turns on or off pretty printing.

Parameters:
  `prettyPrint` - `true` to turn on pretty printing or `false` to turn it off

#### isPrintNamespace

    public boolean isPrintNamespace()

Indicates whether or not the name space should be written on the `<record/>`.

Returns:
  `true` if the name space should be written for each record

#### setPrintNamespace

    public void setPrintNamespace​(boolean printNamespace)

Turns on or off the printing of the namespace for each `<record/>`. This is set to `false` by default.

Parameters:
  `printNamespace` - `true` if the name space should be written for each record

#### getNamespaceUri

    public java.lang.String getNamespaceUri()

Returns the namespace URI used for each record if `isPrintNamespace()` is `true`.

Returns:
  the namespace URI, may be `null` if explicitly set to `null`

#### setNamespaceUri

    public void setNamespaceUri​(java.lang.String namespaceUri)

Sets the namespace URI used for each record if `isPrintNamespace()` is `true`.

Parameters:
  `namespaceUri` - the namespace to use or `null` if no namespace URI should be used regardless of the `isPrintNamespace()` value

#### createGenerator

    protected StructuredFormatter.Generator createGenerator​(java.io.Writer writer)
                                                     throws java.lang.Exception

Description copied from class: `StructuredFormatter`
Creates the generator used to create the structured data.

Specified by:
  `createGenerator` in class `StructuredFormatter`
Returns:
  the generator to use
Throws:
  `java.lang.Exception` - if an error occurs creating the generator