Package org.apache.logging.log4j.message
Enum MapMessageJsonFormatter
- All Implemented Interfaces:
Serializable,Comparable<MapMessageJsonFormatter>,java.lang.constant.Constable
The default JSON formatter for
MapMessages.
The following types have specific handlers:
MapCollection(List,Set, etc.)Number(BigDecimal,Double,Long,Byte, etc.)BooleanStringBuilderFormattable- char/boolean/byte/short/int/long/float/double/Object arrays
String
It supports nesting up to a maximum depth of 8, which is set by log4j2.mapMessage.jsonFormatter.maxDepth property.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidformat(StringBuilder sb, Object object) private static voidformat(StringBuilder sb, Object object, int depth) private static voidformatBoolean(StringBuilder sb, boolean booleanValue) private static voidformatBooleanArray(StringBuilder sb, boolean[] items) private static voidformatByteArray(StringBuilder sb, byte[] items) private static voidformatCharArray(StringBuilder sb, char[] items) private static voidformatCollection(StringBuilder sb, Collection<Object> items, int depth) private static voidformatDoubleArray(StringBuilder sb, double[] items) private static voidformatFloatArray(StringBuilder sb, float[] items) private static voidformatFormattable(StringBuilder sb, StringBuilderFormattable formattable) private static voidformatIndexedStringMap(StringBuilder sb, IndexedStringMap map, int depth) private static voidformatIntArray(StringBuilder sb, int[] items) private static voidformatList(StringBuilder sb, List<Object> items, int depth) private static voidformatLongArray(StringBuilder sb, long[] items) private static voidformatMap(StringBuilder sb, Map<Object, Object> map, int depth) private static voidformatNumber(StringBuilder sb, Number number) private static voidformatObjectArray(StringBuilder sb, Object[] items, int depth) private static voidformatShortArray(StringBuilder sb, short[] items) private static voidformatString(StringBuilder sb, Object value) private static intstatic MapMessageJsonFormatterReturns the enum constant of this type with the specified name.static MapMessageJsonFormatter[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Field Details
-
MAX_DEPTH
public static final int MAX_DEPTH -
DQUOTE
private static final char DQUOTE- See Also:
-
RBRACE
private static final char RBRACE- See Also:
-
LBRACE
private static final char LBRACE- See Also:
-
COMMA
private static final char COMMA- See Also:
-
RCURLY
private static final char RCURLY- See Also:
-
LCURLY
private static final char LCURLY- See Also:
-
COLON
private static final char COLON- See Also:
-
-
Constructor Details
-
MapMessageJsonFormatter
private MapMessageJsonFormatter()
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
readMaxDepth
private static int readMaxDepth() -
format
-
format
-
formatIndexedStringMap
-
formatMap
-
formatList
-
formatCollection
-
formatNumber
-
formatBoolean
-
formatFormattable
-
formatCharArray
-
formatBooleanArray
-
formatByteArray
-
formatShortArray
-
formatIntArray
-
formatLongArray
-
formatFloatArray
-
formatDoubleArray
-
formatObjectArray
-
formatString
-