Class 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;

Author:
James R. Perkins
  • Constructor Details

    • JsonFormatter

      public JsonFormatter()
      Creates a new JSON formatter.
    • JsonFormatter

      public JsonFormatter(String keyOverrides)
      Creates a new JSON formatter.
      Parameters:
      keyOverrides - a string representation of a map to override keys
      See Also:
    • JsonFormatter

      public JsonFormatter(Map<StructuredFormatter.Key,String> keyOverrides)
      Creates a new JSON formatter.
      Parameters:
      keyOverrides - a map of overrides for the default keys
  • Method Details

    • 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(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