public class JsonLayout extends JsonLayoutBase<ch.qos.logback.classic.spi.ILoggingEvent>
jsonMap from a
source ILoggingEvent with the following keys/value pairs:
| Key | Value | Notes | Enabled by default? |
|---|---|---|---|
timestamp |
String value of ILoggingEvent. |
By default, the value is not formatted; it is simply String.valueOf(timestamp). To format
the string using a SimpleDateFormat, set the timestampFormat
property with the corresponding SimpleDateFormat string, for example, yyyy-MM-dd HH:mm:ss.SSS |
true |
level |
String value of ILoggingEvent. |
String.valueOf(event.getLevel()); |
true |
thread |
ILoggingEvent. |
true | |
mdc |
ILoggingEvent. |
Unlike the other values which are all Strings, this value is a Map<String,String>. If there is no
MDC, this property will not be added to the JSON map. |
true |
thread |
ILoggingEvent. |
true | |
message |
ILoggingEvent. |
This is the formatted message. The raw (unformatted) message is available as raw-message.
Most people will want the formatted message as the raw message does not reflect any log message arguments. |
true |
raw-message |
ILoggingEvent. |
false | |
exception |
ILoggingEvent. |
If there is no exception, this property will not be added to the JSON map. If there is an exception, it
will be formatted to a String first via a ThrowableProxyConverter. |
true |
context |
ILoggingEvent. |
The name of the logger context. Defaults to default. | true |
jsonFormatter.| Modifier and Type | Field and Description |
|---|---|
static String |
CONTEXT_ATTR_NAME |
static String |
EXCEPTION_ATTR_NAME |
static String |
FORMATTED_MESSAGE_ATTR_NAME |
protected boolean |
includeContextName |
protected boolean |
includeException |
protected boolean |
includeFormattedMessage |
protected boolean |
includeLevel |
protected boolean |
includeLoggerName |
protected boolean |
includeMDC |
protected boolean |
includeMessage |
protected boolean |
includeThreadName |
static String |
LEVEL_ATTR_NAME |
static String |
LOGGER_ATTR_NAME |
static String |
MDC_ATTR_NAME |
static String |
MESSAGE_ATTR_NAME |
static String |
THREAD_ATTR_NAME |
static String |
TIMESTAMP_ATTR_NAME |
appendLineSeparator, CONTENT_TYPE, includeTimestamp, jsonFormatter, timestampFormat, timestampFormatTimezoneId| Constructor and Description |
|---|
JsonLayout() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCustomDataToJsonMap(Map<String,Object> map,
ch.qos.logback.classic.spi.ILoggingEvent event)
Override to add custom data to the produced JSON from the logging event.
|
boolean |
isIncludeContextName() |
boolean |
isIncludeException() |
boolean |
isIncludeFormattedMessage() |
boolean |
isIncludeLevel() |
boolean |
isIncludeLoggerName() |
boolean |
isIncludeMDC() |
boolean |
isIncludeMessage() |
boolean |
isIncludeThreadName() |
void |
setIncludeContextName(boolean includeContextName) |
void |
setIncludeException(boolean includeException) |
void |
setIncludeFormattedMessage(boolean includeFormattedMessage) |
void |
setIncludeLevel(boolean includeLevel) |
void |
setIncludeLoggerName(boolean includeLoggerName) |
void |
setIncludeMDC(boolean includeMDC) |
void |
setIncludeMessage(boolean includeMessage) |
void |
setIncludeThreadName(boolean includeThreadName) |
void |
start() |
void |
stop() |
protected Map |
toJsonMap(ch.qos.logback.classic.spi.ILoggingEvent event) |
createDateFormat, doLayout, format, formatTimestamp, getContentType, getJsonFormatter, getTimestampFormat, getTimestampFormatTimezoneId, isAppendLineSeparator, isIncludeTimestamp, setAppendLineSeparator, setIncludeTimestamp, setJsonFormatter, setTimestampFormat, setTimestampFormatTimezoneIdgetContext, getFileFooter, getFileHeader, getPresentationFooter, getPresentationHeader, isStarted, setContext, setFileFooter, setFileHeader, setPresentationFooter, setPresentationHeaderaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getDeclaredOrigin, getStatusManagerpublic static final String TIMESTAMP_ATTR_NAME
public static final String LEVEL_ATTR_NAME
public static final String THREAD_ATTR_NAME
public static final String MDC_ATTR_NAME
public static final String LOGGER_ATTR_NAME
public static final String FORMATTED_MESSAGE_ATTR_NAME
public static final String MESSAGE_ATTR_NAME
public static final String EXCEPTION_ATTR_NAME
public static final String CONTEXT_ATTR_NAME
protected boolean includeLevel
protected boolean includeThreadName
protected boolean includeMDC
protected boolean includeLoggerName
protected boolean includeFormattedMessage
protected boolean includeMessage
protected boolean includeException
protected boolean includeContextName
public void start()
start in interface ch.qos.logback.core.spi.LifeCyclestart in class ch.qos.logback.core.LayoutBase<ch.qos.logback.classic.spi.ILoggingEvent>public void stop()
stop in interface ch.qos.logback.core.spi.LifeCyclestop in class ch.qos.logback.core.LayoutBase<ch.qos.logback.classic.spi.ILoggingEvent>protected Map toJsonMap(ch.qos.logback.classic.spi.ILoggingEvent event)
toJsonMap in class JsonLayoutBase<ch.qos.logback.classic.spi.ILoggingEvent>protected void addCustomDataToJsonMap(Map<String,Object> map, ch.qos.logback.classic.spi.ILoggingEvent event)
map - the map for JSON serialization, populated with data corresponding to the
configured attributes. Add new entries from the event to this map to have
them included in the produced JSON.event - the logging event to extract data from.public boolean isIncludeLevel()
public void setIncludeLevel(boolean includeLevel)
public boolean isIncludeLoggerName()
public void setIncludeLoggerName(boolean includeLoggerName)
public boolean isIncludeFormattedMessage()
public void setIncludeFormattedMessage(boolean includeFormattedMessage)
public boolean isIncludeMessage()
public void setIncludeMessage(boolean includeMessage)
public boolean isIncludeMDC()
public void setIncludeMDC(boolean includeMDC)
public boolean isIncludeThreadName()
public void setIncludeThreadName(boolean includeThreadName)
public boolean isIncludeException()
public void setIncludeException(boolean includeException)
public boolean isIncludeContextName()
public void setIncludeContextName(boolean includeContextName)
Copyright © 2012–2016. All rights reserved.