public final class PatternLayout extends AbstractStringLayout
A flexible layout configurable with pattern string. The goal of this class
is to format
a LogEvent
and return the results.
The format of the result depends on the conversion pattern.
The conversion pattern is closely related to the conversion pattern of the printf function in C. A conversion pattern is composed of literal text and format control expressions called conversion specifiers. See the Log4j Manual for details on the supported pattern converters.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONVERSION_PATTERN
Default pattern string for log output.
|
static String |
KEY
Key to identify pattern converters.
|
static String |
SIMPLE_CONVERSION_PATTERN
A simple pattern.
|
static String |
TTCC_CONVERSION_PATTERN
A conversion pattern equivalent to the TTCCCLayout.
|
footer, header, LOGGER
Modifier and Type | Method and Description |
---|---|
static PatternLayout |
createLayout(String pattern,
Configuration config,
RegexReplacement replace,
String charsetName,
String always)
Create a pattern layout.
|
static PatternParser |
createPatternParser(Configuration config)
Create a PatternParser.
|
Map<String,String> |
getContentFormat()
PatternLayout's content format is specified by:
Key: "structured" Value: "false"
Key: "formatType" Value: "conversion" (format uses the keywords supported by OptionConverter)
Key: "format" Value: provided "conversionPattern" param
|
String |
getConversionPattern() |
void |
setConversionPattern(String conversionPattern)
Set the ConversionPattern option.
|
String |
toSerializable(LogEvent event)
Formats a logging event to a writer.
|
String |
toString() |
getCharset, getContentType, toByteArray
getFooter, getHeader, setFooter, setHeader
public static final String DEFAULT_CONVERSION_PATTERN
public static final String TTCC_CONVERSION_PATTERN
public static final String SIMPLE_CONVERSION_PATTERN
public static final String KEY
public void setConversionPattern(String conversionPattern)
conversionPattern
- conversion pattern.public String getConversionPattern()
public Map<String,String> getContentFormat()
public String toSerializable(LogEvent event)
event
- logging event to be formatted.public static PatternParser createPatternParser(Configuration config)
config
- The Configuration.public static PatternLayout createLayout(String pattern, Configuration config, RegexReplacement replace, String charsetName, String always)
pattern
- The pattern. If not specified, defaults to DEFAULT_CONVERSION_PATTERN.config
- The Configuration. Some Converters require access to the Interpolator.replace
- A Regex replacement String.charsetName
- The character set.always
- If "true"
(default) exceptions are always written even if the pattern contains no exception
tokens.Copyright © 1999-2014 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.