Class StackdriverJsonLayout

  • All Implemented Interfaces:
    org.apache.logging.log4j.core.Layout<java.lang.String>, org.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>, org.apache.logging.log4j.core.StringLayout

    @Plugin(name="StackdriverJsonLayout",
            category="Core",
            elementType="layout",
            printObject=true)
    public final class StackdriverJsonLayout
    extends org.apache.logging.log4j.core.layout.AbstractStringLayout
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.ResolvableKeyValuePair[] additionalFields  
      protected boolean compact  
      protected static java.lang.String COMPACT_EOL  
      protected boolean complete  
      protected static java.lang.String DEFAULT_EOL  
      protected java.lang.String eol  
      protected boolean includeNullDelimiter  
      protected com.fasterxml.jackson.databind.ObjectWriter objectWriter  
      • Fields inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout

        DEFAULT_STRING_BUILDER_SIZE, MAX_STRING_BUILDER_SIZE
      • Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout

        configuration, eventCount, footer, header, LOGGER
      • Fields inherited from interface org.apache.logging.log4j.core.Layout

        ELEMENT_TYPE
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static StackdriverJsonLayout createDefaultLayout()
      Creates a JSON Layout using the default settings.
      protected org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.LogEventWithAdditionalFields createLogEventWithAdditionalFields​(org.apache.logging.log4j.core.LogEvent event, java.util.Map<java.lang.String,​java.lang.String> additionalFieldsMap)  
      java.util.Map<java.lang.String,​java.lang.String> getContentFormat()  
      java.lang.String getContentType()  
      byte[] getFooter()
      Returns appropriate JSON footer.
      byte[] getHeader()
      Returns appropriate JSON header.
      static <B extends StackdriverJsonLayout.Builder<B>>
      B
      newBuilder()  
      java.lang.String toSerializable​(org.apache.logging.log4j.core.LogEvent event)
      Formats a LogEvent.
      void toSerializable​(org.apache.logging.log4j.core.LogEvent event, java.io.Writer writer)  
      protected static boolean valueNeedsLookup​(java.lang.String value)  
      protected java.lang.Object wrapLogEvent​(org.apache.logging.log4j.core.LogEvent event)  
      • Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout

        getBytes, getCharset, getFooterSerializer, getHeaderSerializer, getStringBuilder, getStringBuilderEncoder, serializeToBytes, serializeToString, toByteArray, trimToMaxSize
      • Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout

        encode, getConfiguration, markEvent
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.logging.log4j.core.layout.Encoder

        encode
    • Field Detail

      • eol

        protected final java.lang.String eol
      • objectWriter

        protected final com.fasterxml.jackson.databind.ObjectWriter objectWriter
      • compact

        protected final boolean compact
      • complete

        protected final boolean complete
      • includeNullDelimiter

        protected final boolean includeNullDelimiter
      • additionalFields

        protected final org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.ResolvableKeyValuePair[] additionalFields
    • Method Detail

      • createDefaultLayout

        public static StackdriverJsonLayout createDefaultLayout()
        Creates a JSON Layout using the default settings. Useful for testing.
        Returns:
        A JSON Layout.
      • createLogEventWithAdditionalFields

        protected org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.LogEventWithAdditionalFields createLogEventWithAdditionalFields​(org.apache.logging.log4j.core.LogEvent event,
                                                                                                                                                        java.util.Map<java.lang.String,​java.lang.String> additionalFieldsMap)
      • getContentFormat

        public java.util.Map<java.lang.String,​java.lang.String> getContentFormat()
        Specified by:
        getContentFormat in interface org.apache.logging.log4j.core.Layout<java.lang.String>
        Overrides:
        getContentFormat in class org.apache.logging.log4j.core.layout.AbstractLayout<java.lang.String>
      • getContentType

        public java.lang.String getContentType()
        Specified by:
        getContentType in interface org.apache.logging.log4j.core.Layout<java.lang.String>
        Overrides:
        getContentType in class org.apache.logging.log4j.core.layout.AbstractStringLayout
        Returns:
        The content type.
      • getFooter

        @Nullable
        public byte[] getFooter()
        Returns appropriate JSON footer.
        Specified by:
        getFooter in interface org.apache.logging.log4j.core.Layout<java.lang.String>
        Overrides:
        getFooter in class org.apache.logging.log4j.core.layout.AbstractStringLayout
        Returns:
        a byte array containing the footer, closing the JSON array.
      • getHeader

        @Nullable
        public byte[] getHeader()
        Returns appropriate JSON header.
        Specified by:
        getHeader in interface org.apache.logging.log4j.core.Layout<java.lang.String>
        Overrides:
        getHeader in class org.apache.logging.log4j.core.layout.AbstractStringLayout
        Returns:
        a byte array containing the header, opening the JSON array.
      • toSerializable

        public void toSerializable​(org.apache.logging.log4j.core.LogEvent event,
                                   java.io.Writer writer)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • wrapLogEvent

        protected java.lang.Object wrapLogEvent​(org.apache.logging.log4j.core.LogEvent event)
      • valueNeedsLookup

        protected static boolean valueNeedsLookup​(java.lang.String value)
      • toSerializable

        public java.lang.String toSerializable​(org.apache.logging.log4j.core.LogEvent event)
        Formats a LogEvent.
        Parameters:
        event - The LogEvent.
        Returns:
        The XML representation of the LogEvent.