Package org.apache.log4j.bridge
Class LayoutWrapper
- java.lang.Object
-
- org.apache.log4j.Layout
-
- org.apache.log4j.bridge.LayoutWrapper
-
public class LayoutWrapper extends Layout
Bridge between the Log4j 1 Layout and a Log4j 2 Layout.
-
-
Field Summary
Fields Modifier and Type Field Description private Layout<?>layout-
Fields inherited from class org.apache.log4j.Layout
LINE_SEP, LINE_SEP_LEN
-
-
Constructor Summary
Constructors Constructor Description LayoutWrapper(Layout<?> layout)Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Layoutadapt(Layout<?> layout)Adapts a Log4j 2.x layout into a Log4j 1.x layout.java.lang.Stringformat(LoggingEvent event)Implement this method to create your own layout format.Layout<?>getLayout()Unwraps.booleanignoresThrowable()If the layout handles the throwable object contained withinLoggingEvent, then the layout should returnfalse.java.lang.StringtoString()-
Methods inherited from class org.apache.log4j.Layout
getContentType, getFooter, getHeader
-
-
-
-
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 ofLayoutAdapter.adapt(Layout)should return the original Log4j 1.x layout.- Parameters:
layout- a Log4j 2.x layout- Returns:
- a Log4j 1.x layout or
nullif the parameter isnull
-
format
public java.lang.String format(LoggingEvent event)
Description copied from class:LayoutImplement this method to create your own layout format.
-
getLayout
public Layout<?> getLayout()
Unwraps.- Returns:
- The wrapped object.
-
ignoresThrowable
public boolean ignoresThrowable()
Description copied from class:LayoutIf the layout handles the throwable object contained withinLoggingEvent, then the layout should returnfalse. Otherwise, if the layout ignores throwable object, then the layout should returntrue. If ignoresThrowable is true, the appender is responsible for rendering the throwable.The SimpleLayout, TTCCLayout, PatternLayout all return
true. The XMLLayout returnsfalse.- Specified by:
ignoresThrowablein classLayout- Returns:
- true if the Layout ignores Throwables.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-