Package org.jboss.logmanager.formatters

## Class JsonFormatter

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

    public class JsonFormatter
    extends StructuredFormatter

A formatter that outputs the record into JSON format optionally printing details.

Note that including details can be expensive in terms of calculating the caller.

The details include;

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

Author:
  James R. Perkins

### Nested Class Summary

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

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

### Constructor Summary

Constructors
`JsonFormatter()` Creates a new JSON formatter.
`JsonFormatter​(java.lang.String keyOverrides)` Creates a new JSON formatter.
`JsonFormatter​(java.util.Map<StructuredFormatter.Key,java.lang.String> keyOverrides)` Creates a new JSON 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.
`boolean` `isPrettyPrint()` Indicates whether or not pretty printing is enabled.
`void` `setPrettyPrint​(boolean prettyPrint)` Turns on or off pretty printing.

### 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`

### Constructor Detail

#### JsonFormatter

    public JsonFormatter()

Creates a new JSON formatter.

#### JsonFormatter

    public JsonFormatter​(java.lang.String keyOverrides)

Creates a new JSON formatter.

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

#### JsonFormatter

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

Creates a new JSON formatter.

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

#### createGenerator

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

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