Class LayoutWrapper


  • public class LayoutWrapper
    extends Layout
    Bridge between the Log4j 1 Layout and a Log4j 2 Layout.
    • Field Detail

      • layout

        private final Layout<?> layout
    • Constructor Detail

      • LayoutWrapper

        public LayoutWrapper​(Layout<?> layout)
        Constructs a new instance.
        Parameters:
        layout - The layout to wrap.
    • Method Detail

      • adapt

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

        public java.lang.String format​(LoggingEvent event)
        Description copied from class: Layout
        Implement this method to create your own layout format.
        Specified by:
        format in class Layout
        Parameters:
        event - The LoggingEvent.
        Returns:
        The formatted LoggingEvent.
      • getLayout

        public Layout<?> getLayout()
        Unwraps.
        Returns:
        The wrapped object.
      • ignoresThrowable

        public boolean ignoresThrowable()
        Description copied from class: Layout
        If the layout handles the throwable object contained within LoggingEvent, then the layout should return false. Otherwise, if the layout ignores throwable object, then the layout should return true. If ignoresThrowable is true, the appender is responsible for rendering the throwable.

        The SimpleLayout, TTCCLayout, PatternLayout all return true. The XMLLayout returns false.

        Specified by:
        ignoresThrowable in class Layout
        Returns:
        true if the Layout ignores Throwables.
      • toString

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