Class SerializedLayout

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

@Deprecated @Plugin(name="SerializedLayout", category="Core", elementType="layout", printObject=true) public final class SerializedLayout extends AbstractLayout<LogEvent>
Deprecated.
Java Serialization has inherent security weaknesses, see https://www.owasp.org/index.php/Deserialization_of_untrusted_data . Using this layout is no longer recommended. An alternative layout containing the same information is JsonLayout when configured with properties="true". Deprecated since 2.9.
Formats a LogEvent in its Java serialized form.
  • Method Details

    • toByteArray

      public byte[] toByteArray(LogEvent event)
      Deprecated.
      Formats a LogEvent as a serialized byte array of the LogEvent object.
      Parameters:
      event - The LogEvent.
      Returns:
      the formatted LogEvent.
    • toSerializable

      public LogEvent toSerializable(LogEvent event)
      Deprecated.
      Returns the LogEvent.
      Parameters:
      event - The Logging Event.
      Returns:
      The LogEvent.
    • createLayout

      @Deprecated @PluginFactory public static SerializedLayout createLayout()
      Deprecated.
      Creates a SerializedLayout.
      Returns:
      A SerializedLayout.
    • getHeader

      public byte[] getHeader()
      Deprecated.
      Description copied from class: AbstractLayout
      Returns the header, if one is available.
      Specified by:
      getHeader in interface Layout<LogEvent>
      Overrides:
      getHeader in class AbstractLayout<LogEvent>
      Returns:
      A byte array containing the header.
    • getContentType

      public String getContentType()
      Deprecated.
      SerializedLayout returns a binary stream.
      Returns:
      The content type.