Class GelfLayout

    • Field Detail

      • additionalFields

        private final KeyValuePair[] additionalFields
      • compressionThreshold

        private final int compressionThreshold
      • host

        private final java.lang.String host
      • includeStacktrace

        private final boolean includeStacktrace
      • includeThreadContext

        private final boolean includeThreadContext
      • includeMapMessage

        private final boolean includeMapMessage
      • includeNullDelimiter

        private final boolean includeNullDelimiter
      • includeNewLineDelimiter

        private final boolean includeNewLineDelimiter
      • omitEmptyFields

        private final boolean omitEmptyFields
      • messageStringBuilder

        private static final java.lang.ThreadLocal<java.lang.StringBuilder> messageStringBuilder
      • timestampStringBuilder

        private static final java.lang.ThreadLocal<java.lang.StringBuilder> timestampStringBuilder
    • Constructor Detail

      • GelfLayout

        private GelfLayout​(Configuration config,
                           java.lang.String host,
                           KeyValuePair[] additionalFields,
                           GelfLayout.CompressionType compressionType,
                           int compressionThreshold,
                           boolean includeStacktrace,
                           boolean includeThreadContext,
                           boolean includeMapMessage,
                           boolean includeNullDelimiter,
                           boolean includeNewLineDelimiter,
                           boolean omitEmptyFields,
                           ListChecker mdcChecker,
                           ListChecker mapChecker,
                           PatternLayout patternLayout,
                           java.lang.String mdcPrefix,
                           java.lang.String mapPrefix)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getContentFormat

        public java.util.Map<java.lang.String,​java.lang.String> getContentFormat()
        Description copied from interface: Layout
        Returns a description of the content format.
        Specified by:
        getContentFormat in interface Layout<java.lang.String>
        Overrides:
        getContentFormat in class AbstractLayout<java.lang.String>
        Returns:
        a Map of key/value pairs describing the Layout-specific content format, or an empty Map if no content format descriptors are specified.
      • getContentType

        public java.lang.String getContentType()
        Description copied from interface: Layout
        Returns the content type output by this layout. The base class returns "text/plain".
        Specified by:
        getContentType in interface Layout<java.lang.String>
        Overrides:
        getContentType in class AbstractStringLayout
        Returns:
        The default content type for Strings.
      • encode

        public void encode​(LogEvent event,
                           ByteBufferDestination destination)
        Description copied from class: AbstractLayout
        Encodes the specified source LogEvent to some binary representation and writes the result to the specified destination.

        The default implementation of this method delegates to the Layout.toByteArray(LogEvent) method which allocates temporary objects.

        Subclasses can override this method to provide a garbage-free implementation. For text-based layouts, AbstractStringLayout provides various convenience methods to help with this:

        @Plugin(name = "MyLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true)
         public final class MyLayout extends AbstractStringLayout {
        
        Specified by:
        encode in interface Encoder<LogEvent>
        Overrides:
        encode in class AbstractLayout<java.lang.String>
        Parameters:
        event - the LogEvent to encode.
        destination - holds the ByteBuffer to write into.
        See Also:
        AbstractStringLayout.getStringBuilder(), AbstractStringLayout.getStringBuilderEncoder()
      • compress

        private byte[] compress​(byte[] bytes)
      • toSerializable

        public java.lang.String toSerializable​(LogEvent event)
        Description copied from interface: Layout
        Formats the event as an Object that can be serialized.
        Parameters:
        event - The Logging Event.
        Returns:
        The formatted event.
      • toText

        private java.lang.StringBuilder toText​(LogEvent event,
                                               java.lang.StringBuilder builder,
                                               boolean gcFree)
      • valueNeedsLookup

        private static boolean valueNeedsLookup​(java.lang.String value)
      • getMessageStringBuilder

        private static java.lang.StringBuilder getMessageStringBuilder()
      • toNullSafeString

        private static java.lang.CharSequence toNullSafeString​(java.lang.CharSequence s)
      • formatTimestamp

        static java.lang.CharSequence formatTimestamp​(long timeMillis)
        Non-private to make it accessible from unit test.
      • getTimestampStringBuilder

        private static java.lang.StringBuilder getTimestampStringBuilder()
      • formatLevel

        private int formatLevel​(Level level)
        http://en.wikipedia.org/wiki/Syslog#Severity_levels
      • formatThrowable

        static java.lang.CharSequence formatThrowable​(java.lang.Throwable throwable)
        Non-private to make it accessible from unit test.