Class LayoutAdapter

  • All Implemented Interfaces:
    Layout<java.lang.String>, Encoder<LogEvent>

    public class LayoutAdapter
    extends java.lang.Object
    implements Layout<java.lang.String>
    Class Description goes here.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Layout layout  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LayoutAdapter​(Layout layout)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Layout<?> adapt​(Layout layout)
      Adapts a Log4j 1.x layout into a Log4j 2.x layout.
      void encode​(LogEvent event, ByteBufferDestination destination)
      Encodes the specified source object to some binary representation and writes the result to the specified destination.
      java.util.Map<java.lang.String,​java.lang.String> getContentFormat()
      Returns a description of the content format.
      java.lang.String getContentType()
      Returns the content type output by this layout.
      byte[] getFooter()
      Returns the format for the layout format.
      byte[] getHeader()
      Returns the header for the layout format.
      Layout getLayout()  
      byte[] toByteArray​(LogEvent event)
      Formats the event suitable for display.
      java.lang.String toSerializable​(LogEvent event)
      Formats the event as an Object that can be serialized.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • layout

        private Layout layout
    • Constructor Detail

      • LayoutAdapter

        private LayoutAdapter​(Layout layout)
    • Method Detail

      • adapt

        public static Layout<?> adapt​(Layout layout)
        Adapts a Log4j 1.x layout into a Log4j 2.x layout. Applying this method to the result of LayoutWrapper.adapt(org.apache.logging.log4j.core.Layout) should return the original Log4j 2.x layout.
        Parameters:
        layout - a Log4j 1.x layout
        Returns:
        a Log4j 2.x layout or null if the parameter is null
      • getLayout

        public Layout getLayout()
      • getFooter

        public byte[] getFooter()
        Description copied from interface: Layout
        Returns the format for the layout format.
        Specified by:
        getFooter in interface Layout<java.lang.String>
        Returns:
        The footer.
      • getHeader

        public byte[] getHeader()
        Description copied from interface: Layout
        Returns the header for the layout format.
        Specified by:
        getHeader in interface Layout<java.lang.String>
        Returns:
        The header.
      • toByteArray

        public byte[] toByteArray​(LogEvent event)
        Description copied from interface: Layout
        Formats the event suitable for display.
        Specified by:
        toByteArray in interface Layout<java.lang.String>
        Parameters:
        event - The Logging Event.
        Returns:
        The formatted event.
      • toSerializable

        public java.lang.String toSerializable​(LogEvent event)
        Description copied from interface: Layout
        Formats the event as an Object that can be serialized.
        Specified by:
        toSerializable in interface Layout<java.lang.String>
        Parameters:
        event - The Logging Event.
        Returns:
        The formatted event.
      • 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>
        Returns:
        the content type.
      • 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>
        Returns:
        a Map of key/value pairs describing the Layout-specific content format, or an empty Map if no content format descriptors are specified.
      • encode

        public void encode​(LogEvent event,
                           ByteBufferDestination destination)
        Description copied from interface: Encoder
        Encodes the specified source object to some binary representation and writes the result to the specified destination.
        Specified by:
        encode in interface Encoder<LogEvent>
        Parameters:
        event - the object to encode.
        destination - holds the ByteBuffer to write into.