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.layout
Class HtmlLayout

    java.lang.Object
      org.apache.logging.log4j.core.layout.AbstractLayout<String>
          org.apache.logging.log4j.core.layout.AbstractStringLayout
              org.apache.logging.log4j.core.layout.HtmlLayout

All Implemented Interfaces:
  Serializable, Layout<String>

    @Plugin(name="HtmlLayout",
            category="Core",
            elementType="layout",
            printObject=true)
    public final class HtmlLayout

extends AbstractStringLayout

Outputs events as rows in an HTML table on an HTML page.

Appenders using this layout should have their encoding set to UTF-8 or UTF-16, otherwise events containing non ASCII characters could result in corrupted log files.

See Also:
  Serialized Form

Nested Class Summary
`static class` | `HtmlLayout.Builder`
`static class` | `HtmlLayout.FontSize` Possible font sizes

Field Summary
`static String` | `DEFAULT_FONT_FAMILY`

Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
`footer, header, LOGGER`

Fields inherited from interface org.apache.logging.log4j.core.Layout
`ELEMENT_TYPE`

Method Summary
`static HtmlLayout` | `createDefaultLayout()` Creates an HTML Layout using the default settings.
`static HtmlLayout` | `createLayout(boolean locationInfo, String title, String contentType, Charset charset, String fontSize, String font)` Create an HTML Layout.
`String` | `getContentType()` Returns the content type output by this layout.
`byte[]` | `getFooter()` Returns the appropriate HTML footers.
`byte[]` | `getHeader()` Returns appropriate HTML headers.
`static HtmlLayout.Builder` | `newBuilder()`
`String` | `toSerializable(LogEvent event)` Format as a String.

Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
`getBytes, getCharset, toByteArray`

Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
`getContentFormat`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_FONT_FAMILY

    public static final String DEFAULT_FONT_FAMILY

See Also:
  Constant Field Values

Method Detail

### toSerializable

    public String toSerializable(LogEvent event)

  Format as a String.

  Parameters:
    `event` - The Logging Event.
  Returns:
    A String containing the LogEvent as HTML.

### getContentType

    public String getContentType()

  Description copied from interface: `Layout`
  Returns the content type output by this layout. The base class returns "text/plain".

  Specified by:
    `getContentType` in interface `Layout<String>`
  Overrides:
    `getContentType` in class `AbstractStringLayout`
  Returns:
    The default content type for Strings.

### getHeader

    public byte[] getHeader()

  Returns appropriate HTML headers.

  Specified by:
    `getHeader` in interface `Layout<String>`
  Overrides:
    `getHeader` in class `AbstractLayout<String>`
  Returns:
    The header as a byte array.

### getFooter

    public byte[] getFooter()

  Returns the appropriate HTML footers.

  Specified by:
    `getFooter` in interface `Layout<String>`
  Overrides:
    `getFooter` in class `AbstractLayout<String>`
  Returns:
    the footer as a byet array.

### createLayout

    @PluginFactory
    public static HtmlLayout createLayout(@PluginAttribute(value="locationInfo",defaultBoolean=false)
                                                        boolean locationInfo,
                                                        @PluginAttribute(value="title",defaultString="Log4j Log Messages")
                                                        String title,
                                                        @PluginAttribute(value="contentType")
                                                        String contentType,
                                                        @PluginAttribute(value="charset",defaultString="UTF-8")
                                                        Charset charset,
                                                        @PluginAttribute(value="fontSize")
                                                        String fontSize,
                                                        @PluginAttribute(value="fontName",defaultString="arial,sans-serif")
                                                        String font)

  Create an HTML Layout.

  Parameters:
    `locationInfo` - If "true", location information will be included. The default is false.
    `title` - The title to include in the file header. If none is specified the default title will be used.
    `contentType` - The content type. Defaults to "text/html".
    `charset` - The character set to use. If not specified, the default will be used.
    `fontSize` - The font size of the text.
    `font` - The font to use for the text.
  Returns:
    An HTML Layout.

### createDefaultLayout

    public static HtmlLayout createDefaultLayout()

  Creates an HTML Layout using the default settings.

  Returns:
    an HTML Layout.

### newBuilder

    @PluginBuilderFactory
    public static HtmlLayout.Builder newBuilder()

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.