Class ESLogMessage

java.lang.Object
org.apache.logging.log4j.message.MapMessage<ESLogMessage,Object>
org.elasticsearch.common.logging.ESLogMessage
All Implemented Interfaces:
Serializable, org.apache.logging.log4j.message.Message, org.apache.logging.log4j.message.MultiformatMessage, org.apache.logging.log4j.util.MultiFormatStringBuilderFormattable, org.apache.logging.log4j.util.StringBuilderFormattable

public class ESLogMessage extends org.apache.logging.log4j.message.MapMessage<ESLogMessage,Object>
A base class for custom log4j logger messages. Carries additional fields which will populate JSON fields in logs.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.logging.log4j.message.MapMessage

    org.apache.logging.log4j.message.MapMessage.MapFormat
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ESLogMessage(String messagePattern, Object... args)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    This method is used in order to support ESJsonLayout which replaces %CustomMapFields from a pattern with JSON fields It is a modified version of MapMessage.asJson(StringBuilder) where the curly brackets are not added
    argAndField(String key, Object value)
     
    static String
     
    field(String key, Object value)
     
     
     
    static String
     
    static String
     
    withFields(Map<String,Object> prepareMap)
     

    Methods inherited from class org.apache.logging.log4j.message.MapMessage

    appendMap, asJava, asJavaUnquoted, asJson, asString, asString, asXml, clear, containsKey, equals, forEach, forEach, formatTo, formatTo, get, getData, getFormat, getFormats, getFormattedMessage, getFormattedMessage, getIndexedReadOnlyStringMap, getParameters, getThrowable, hashCode, newInstance, put, putAll, remove, toKey, toString, validate, validate, validate, validate, validate, validate, validate, validate, validate, validate, with, with, with, with, with, with, with, with, with, with

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ESLogMessage

      public ESLogMessage(String messagePattern, Object... args)
    • ESLogMessage

      public ESLogMessage()
  • Method Details

    • argAndField

      public ESLogMessage argAndField(String key, Object value)
    • field

      public ESLogMessage field(String key, Object value)
    • withFields

      public ESLogMessage withFields(Map<String,Object> prepareMap)
    • addJsonNoBrackets

      protected void addJsonNoBrackets(StringBuilder sb)
      This method is used in order to support ESJsonLayout which replaces %CustomMapFields from a pattern with JSON fields It is a modified version of MapMessage.asJson(StringBuilder) where the curly brackets are not added
      Parameters:
      sb - a string builder where JSON fields will be attached
    • inQuotes

      public static String inQuotes(String s)
    • inQuotes

      public static String inQuotes(Object s)
    • asJsonArray

      public static String asJsonArray(Stream<String> stream)
    • getArguments

      public Object[] getArguments()
    • getMessagePattern

      public String getMessagePattern()