Class MessageLayout

java.lang.Object
org.apache.logging.log4j.core.layout.AbstractLayout<Message>
org.apache.logging.log4j.core.layout.MessageLayout
All Implemented Interfaces:
Layout<Message>, Encoder<LogEvent>

@Plugin(name="MessageLayout", category="Core", elementType="layout", printObject=true) public class MessageLayout extends AbstractLayout<Message>
Formats a LogEvent in its Message form.

Useful in combination with a JMS Appender to map a Log4j MapMessage or StringMapMessage to a JMS MapMessage.

  • Constructor Details

    • MessageLayout

      public MessageLayout()
    • MessageLayout

      public MessageLayout(Configuration configuration, byte[] header, byte[] footer)
  • Method Details

    • toByteArray

      public byte[] toByteArray(LogEvent event)
      Description copied from interface: Layout
      Formats the event suitable for display.
      Parameters:
      event - The Logging Event.
      Returns:
      The formatted event.
    • toSerializable

      public Message 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.
    • getContentType

      public String getContentType()
      Description copied from interface: Layout
      Returns the content type output by this layout. The base class returns "text/plain".
      Returns:
      the content type.
    • createLayout

      @PluginFactory public static Layout<?> createLayout()