Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.core
Interface Layout<T extends Serializable>

Type Parameters:
  `T` - The `Serializable` type returned by `toSerializable(LogEvent)` TODO There is still a need for a character-based layout for character based event sinks (databases, etc). Would introduce an EventEncoder, EventRenderer or something similar for the logging event to byte encoding. (RG) A layout can be configured with a Charset and then Strings can be converted to byte arrays. OTOH, it isn't possible to write byte arrays as character streams.

All Known Implementing Classes:
  AbstractLayout, AbstractStringLayout, GelfLayout, HtmlLayout, JsonLayout, PatternLayout, Rfc5424Layout, SerializedLayout, SyslogLayout, XmlLayout

    public interface Layout<T extends Serializable>

Lays out a LogEvent in different formats. The formats are:

- `byte[]`
- an implementer of Serializable, like `byte[]`
- String
- LogEvent

Field Summary
`static String` | `ELEMENT_TYPE` Main plugin element type for Layout plugins.

Method Summary
`Map<String,String>` | `getContentFormat()` Returns a description of the content format.
`String` | `getContentType()` Returns the content type output by this layout.
`byte[]` | `getFooter()` Returns the format for the layout format.
`byte[]` | `getHeader()` Returns the header for the layout format.
`byte[]` | `toByteArray(LogEvent event)` Formats the event suitable for display.
`T` | `toSerializable(LogEvent event)` Formats the event as an Object that can be serialized.

Field Detail

### ELEMENT_TYPE

    static final String ELEMENT_TYPE

  Main plugin element type for Layout plugins.

  Since:
    2.1
  See Also:
    Constant Field Values

Method Detail

### getFooter

    byte[] getFooter()

  Returns the format for the layout format.

  Returns:
    The footer.

### getHeader

    byte[] getHeader()

  Returns the header for the layout format.

  Returns:
    The header.

### toByteArray

    byte[] toByteArray(LogEvent event)

  Formats the event suitable for display.

  Parameters:
    `event` - The Logging Event.
  Returns:
    The formatted event. TODO Likely better to write to a OutputStream instead of return a byte[]. (RG) That limits how the Appender can use the Layout. For example, it might concatenate information in front or behind the data and then write it all to the OutputStream in one call.

### toSerializable

    T toSerializable(LogEvent event)

  Formats the event as an Object that can be serialized.

  Parameters:
    `event` - The Logging Event.
  Returns:
    The formatted event.

### getContentType

    String getContentType()

  Returns the content type output by this layout. The base class returns "text/plain".

  Returns:
    the content type.

### getContentFormat

    Map<String,String> getContentFormat()

  Returns a description of the content format.

  Returns:
    a Map of key/value pairs describing the Layout-specific content format, or an empty Map if no content format descriptors are specified.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.