public class JsonLayout extends AbstractJsonLayout<ch.qos.logback.classic.spi.ILoggingEvent>
ILoggingEvent as a JSON string. This supports Elasticsearch
without the need for Logstash (as well as any other JSON-consuming endpoint).
The JSON object will always contain the following properties:
timestamp: the date/time that the message was logged.
thread: the name of the thread where the message was logged.
logger: the name of the logger.
level: the level of this log message.
message: the message itself.
hostname: the name of the machine where the logger is running, if
available (this is currently retrieved from
RuntimeMxBean and may not be available on
all platforms).
processId: the PID of the invoking process, if available (this is
retrieved from RuntimeMxBean and may not be
available on all platforms).
The following properties will only appear if they are present in the event:
exception: an exception with stack trace. This is an array, with the
first element identifying the exception and message, and
subsequent elements identifying the stack trace.
mdc: the mapped diagnostic context. This is a child object.
The following properties are potentially expensive to compute, so will only appear if specifically enabled via configuration:
locationInfo: the location where the logger was invoked. This is a
child object with the following components:
className
methodName
fileName
lineNumber
instanceId: the EC2 instance ID of the machine where the logger is
running. WARNING: do not enable this elsewhere, as the
operation to retrieve this value may take a long time.
accountId: the AWS account ID associated with the current user/role.
Lastly, you can define a set of user tags, which are written as a child object with
the key tags. These are intended to provide program-level information,
in the case where multiple programs send their logs to the same stream. They are set
as a single comma-separate string, which may contain substitution values (example:
appName=Fribble,startedAt={startupTimestamp}).
WARNING: you should not rely on the order in which elements are output. Any apparent ordering is an implementation artifact and subject to change without notice.
| Constructor and Description |
|---|
JsonLayout() |
| Modifier and Type | Method and Description |
|---|---|
String |
doLayout(ch.qos.logback.classic.spi.ILoggingEvent event) |
boolean |
getEnableLocation() |
void |
setEnableLocation(boolean value) |
addCommonAttributesAndConvert, getAppendNewlines, getEnableAccountId, getEnableHostname, getEnableInstanceId, getTags, setAppendNewlines, setEnableAccountId, setEnableHostname, setEnableInstanceId, setTags, start, stopgetContentType, getContext, getFileFooter, getFileHeader, getPresentationFooter, getPresentationHeader, isStarted, setContext, setFileFooter, setFileHeader, setPresentationFooter, setPresentationHeaderaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getDeclaredOrigin, getStatusManagerpublic void setEnableLocation(boolean value)
public boolean getEnableLocation()
public String doLayout(ch.qos.logback.classic.spi.ILoggingEvent event)
Copyright © 2020. All rights reserved.