Class AbstractStringLayout

    • Field Detail

      • DEFAULT_STRING_BUILDER_SIZE

        protected static final int DEFAULT_STRING_BUILDER_SIZE
        Default length for new StringBuilder instances: 1024 .
        See Also:
        Constant Field Values
      • MAX_STRING_BUILDER_SIZE

        protected static final int MAX_STRING_BUILDER_SIZE
    • Constructor Detail

      • AbstractStringLayout

        protected AbstractStringLayout​(Charset charset)
      • AbstractStringLayout

        protected AbstractStringLayout​(Charset aCharset,
                                       byte[] header,
                                       byte[] footer)
        Builds a new layout.
        Parameters:
        aCharset - the charset used to encode the header bytes, footer bytes and anything else that needs to be converted from strings to bytes.
        header - the header bytes
        footer - the footer bytes
      • AbstractStringLayout

        protected AbstractStringLayout​(Configuration config,
                                       Charset aCharset,
                                       AbstractStringLayout.Serializer headerSerializer,
                                       AbstractStringLayout.Serializer footerSerializer)
        Builds a new layout.
        Parameters:
        config - the configuration
        aCharset - the charset used to encode the header bytes, footer bytes and anything else that needs to be converted from strings to bytes.
        headerSerializer - the header bytes serializer
        footerSerializer - the footer bytes serializer
    • Method Detail

      • getStringBuilder

        protected static StringBuilder getStringBuilder()
        Returns a StringBuilder that this Layout implementation can use to write the formatted log event to.
        Returns:
        a StringBuilder
      • trimToMaxSize

        protected static void trimToMaxSize​(StringBuilder stringBuilder)
      • getBytes

        protected byte[] getBytes​(String s)
      • getCharset

        public Charset getCharset()
        Description copied from interface: StringLayout
        Gets the Charset this layout uses to encode Strings into bytes.
        Specified by:
        getCharset in interface StringLayout
        Returns:
        the Charset this layout uses to encode Strings into bytes.
      • getContentType

        public 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<String>
        Returns:
        The default content type for Strings.
      • getStringBuilderEncoder

        protected Encoder<StringBuilder> getStringBuilderEncoder()
        Returns a Encoder<StringBuilder> that this Layout implementation can use for encoding log events.
        Returns:
        a Encoder<StringBuilder>
      • toByteArray

        public byte[] toByteArray​(LogEvent event)
        Formats the Log Event as a byte array.
        Specified by:
        toByteArray in interface Layout<String>
        Parameters:
        event - The Log Event.
        Returns:
        The formatted event as a byte array.