@Plugin(name="HtmlLayout", category="Core", elementType="layout", printObject=true) public final class HtmlLayout extends AbstractStringLayout
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
HtmlLayout.Builder |
static class |
HtmlLayout.FontSize
Possible font sizes
|
AbstractStringLayout.Serializer, AbstractStringLayout.Serializer2| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
contentType |
private static java.lang.String |
DEFAULT_CONTENT_TYPE |
static java.lang.String |
DEFAULT_FONT_FAMILY
Default font family: "arial,sans-serif".
|
private static java.lang.String |
DEFAULT_TITLE |
private java.lang.String |
font |
private java.lang.String |
fontSize |
private java.lang.String |
headerSize |
private long |
jvmStartTime |
private boolean |
locationInfo |
private static java.lang.String |
REGEXP |
private java.lang.String |
title |
private static java.lang.String |
TRACE_PREFIX |
DEFAULT_STRING_BUILDER_SIZE, MAX_STRING_BUILDER_SIZEconfiguration, eventCount, footer, header, LOGGERELEMENT_TYPE| Modifier | Constructor and Description |
|---|---|
private |
HtmlLayout(boolean locationInfo,
java.lang.String title,
java.lang.String contentType,
java.nio.charset.Charset charset,
java.lang.String font,
java.lang.String fontSize,
java.lang.String headerSize) |
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
addCharsetToContentType(java.lang.String contentType) |
private java.lang.StringBuilder |
append(java.lang.StringBuilder sbuilder,
java.lang.String s) |
private java.lang.StringBuilder |
appendLs(java.lang.StringBuilder sbuilder,
java.lang.String s) |
private void |
appendThrowableAsHtml(java.lang.Throwable throwable,
java.lang.StringBuilder sbuf) |
static HtmlLayout |
createDefaultLayout()
Creates an HTML Layout using the default settings.
|
static HtmlLayout |
createLayout(boolean locationInfo,
java.lang.String title,
java.lang.String contentType,
java.nio.charset.Charset charset,
java.lang.String fontSize,
java.lang.String font)
Creates an HTML Layout.
|
java.lang.String |
getContentType()
Returns the content type output by this layout.
|
byte[] |
getFooter()
Returns the appropriate HTML footers.
|
byte[] |
getHeader()
Returns appropriate HTML headers.
|
java.lang.String |
getTitle()
For testing purposes.
|
boolean |
isLocationInfo()
For testing purposes.
|
static HtmlLayout.Builder |
newBuilder() |
java.lang.String |
toSerializable(LogEvent event)
Formats as a String.
|
getBytes, getCharset, getFooterSerializer, getHeaderSerializer, getStringBuilder, getStringBuilderEncoder, serializeToBytes, serializeToString, toByteArray, trimToMaxSizeencode, getConfiguration, getContentFormat, markEvent, writeToclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetContentFormatpublic static final java.lang.String DEFAULT_FONT_FAMILY
private static final java.lang.String TRACE_PREFIX
private static final java.lang.String REGEXP
private static final java.lang.String DEFAULT_TITLE
private static final java.lang.String DEFAULT_CONTENT_TYPE
private final long jvmStartTime
private final boolean locationInfo
private final java.lang.String title
private final java.lang.String contentType
private final java.lang.String font
private final java.lang.String fontSize
private final java.lang.String headerSize
private HtmlLayout(boolean locationInfo,
java.lang.String title,
java.lang.String contentType,
java.nio.charset.Charset charset,
java.lang.String font,
java.lang.String fontSize,
java.lang.String headerSize)
public java.lang.String getTitle()
public boolean isLocationInfo()
private java.lang.String addCharsetToContentType(java.lang.String contentType)
public java.lang.String toSerializable(LogEvent event)
event - The Logging Event.public java.lang.String getContentType()
LayoutgetContentType in interface Layout<java.lang.String>getContentType in class AbstractStringLayoutprivate void appendThrowableAsHtml(java.lang.Throwable throwable,
java.lang.StringBuilder sbuf)
private java.lang.StringBuilder appendLs(java.lang.StringBuilder sbuilder,
java.lang.String s)
private java.lang.StringBuilder append(java.lang.StringBuilder sbuilder,
java.lang.String s)
public byte[] getHeader()
getHeader in interface Layout<java.lang.String>getHeader in class AbstractStringLayoutpublic byte[] getFooter()
getFooter in interface Layout<java.lang.String>getFooter in class AbstractStringLayout@PluginFactory public static HtmlLayout createLayout(@PluginAttribute(value="locationInfo") boolean locationInfo, @PluginAttribute(value="title",defaultString="Log4j Log Messages") java.lang.String title, @PluginAttribute(value="contentType") java.lang.String contentType, @PluginAttribute(value="charset",defaultString="UTF-8") java.nio.charset.Charset charset, @PluginAttribute(value="fontSize") java.lang.String fontSize, @PluginAttribute(value="fontName",defaultString="arial,sans-serif") java.lang.String font)
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.public static HtmlLayout createDefaultLayout()
@PluginBuilderFactory public static HtmlLayout.Builder newBuilder()