Class Log4j1XmlLayout

All Implemented Interfaces:
LocationAware, Layout<String>, Encoder<LogEvent>, StringLayout

@Plugin(name="Log4j1XmlLayout", category="Core", elementType="layout", printObject=true) public final class Log4j1XmlLayout extends AbstractStringLayout
Port of XMLLayout in Log4j 1.x. Provided for compatibility with existing Log4j 1 configurations. Originally developed by Ceki Gülcü, Mathias Bogaert.
  • Field Details

    • EOL

      private static final String EOL
      We yield to the \r\n heresy.
      See Also:
    • locationInfo

      private final boolean locationInfo
    • properties

      private final boolean properties
  • Constructor Details

    • Log4j1XmlLayout

      private Log4j1XmlLayout(boolean locationInfo, boolean properties)
  • Method Details

    • createLayout

      @PluginFactory public static Log4j1XmlLayout createLayout(@PluginAttribute("locationInfo") boolean locationInfo, @PluginAttribute("properties") boolean properties)
    • isLocationInfo

      public boolean isLocationInfo()
    • isProperties

      public boolean isProperties()
    • 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<String>
      Parameters:
      event - the LogEvent to encode.
      destination - holds the ByteBuffer to write into.
      See Also:
    • toSerializable

      public 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.
    • formatTo

      private void formatTo(LogEvent event, StringBuilder buf)