public abstract class AbstractStringLayout extends AbstractLayout<String> implements StringLayout
Since 2.4.1, this class has custom logic to convert ISO-8859-1 or US-ASCII Strings to byte[] arrays to improve performance: all characters are simply cast to bytes.
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_STRING_BUILDER_SIZE
Default length for new StringBuilder instances: 1024 .
|
footer, header, LOGGER
ELEMENT_TYPE
Modifier | Constructor and Description |
---|---|
protected |
AbstractStringLayout(Charset charset) |
protected |
AbstractStringLayout(Charset charset,
byte[] header,
byte[] footer)
Builds a new layout.
|
Modifier and Type | Method and Description |
---|---|
protected byte[] |
getBytes(String s) |
Charset |
getCharset()
Gets the Charset this layout uses to encode Strings into bytes.
|
String |
getContentType()
Returns the content type output by this layout.
|
protected StringBuilder |
getStringBuilder()
Returns a
StringBuilder that this Layout implementation can use to write the formatted log event to. |
byte[] |
toByteArray(LogEvent event)
Formats the Log Event as a byte array.
|
getContentFormat, getFooter, getHeader
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getContentFormat, getFooter, getHeader, toSerializable
protected static final int DEFAULT_STRING_BUILDER_SIZE
protected AbstractStringLayout(Charset charset)
protected AbstractStringLayout(Charset charset, byte[] header, byte[] footer)
charset
- the charset used to encode the header bytes, footer bytes and anything else that needs to be
converted from strings to bytes.header
- the header bytesfooter
- the footer bytesprotected StringBuilder getStringBuilder()
StringBuilder
that this Layout implementation can use to write the formatted log event to.StringBuilder
protected byte[] getBytes(String s)
public Charset getCharset()
StringLayout
getCharset
in interface StringLayout
public String getContentType()
Layout
getContentType
in interface Layout<String>
public byte[] toByteArray(LogEvent event)
toByteArray
in interface Layout<String>
event
- The Log Event.Copyright © 1999-2017 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.