Package io.micronaut.gcp.logging
Class StackdriverJsonLayout
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.LayoutBase<E>
ch.qos.logback.contrib.json.JsonLayoutBase<ch.qos.logback.classic.spi.ILoggingEvent>
ch.qos.logback.contrib.json.classic.JsonLayout
io.micronaut.gcp.logging.StackdriverJsonLayout
- All Implemented Interfaces:
ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.LifeCycle
public class StackdriverJsonLayout
extends ch.qos.logback.contrib.json.classic.JsonLayout
Logback JsonLayout class to include tracing and other MDC fields.
- Since:
- 3.2.0
- Author:
- Vinicius Carvalho
-
Field Summary
Fields inherited from class ch.qos.logback.contrib.json.classic.JsonLayout
CONTEXT_ATTR_NAME, EXCEPTION_ATTR_NAME, FORMATTED_MESSAGE_ATTR_NAME, includeContextName, includeException, includeFormattedMessage, includeLevel, includeLoggerName, includeMDC, includeMessage, includeThreadName, LEVEL_ATTR_NAME, LOGGER_ATTR_NAME, MDC_ATTR_NAME, MESSAGE_ATTR_NAME, THREAD_ATTR_NAME, TIMESTAMP_ATTR_NAMEFields inherited from class ch.qos.logback.contrib.json.JsonLayoutBase
appendLineSeparator, CONTENT_TYPE, includeTimestamp, jsonFormatter, timestampFormat, timestampFormatTimezoneIdFields inherited from class ch.qos.logback.core.LayoutBase
startedFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringformatTraceId(String traceId) Formats traceId to be exact 32 digits.ch.qos.logback.contrib.json.JsonFormatterbooleanbooleanbooleanvoidsetCustomJson(Map<String, Object> customJson) voidsetIncludeExceptionInMessage(boolean includeExceptionInMessage) voidsetIncludeSpanId(boolean includeSpanId) voidsetIncludeTraceId(boolean includeTraceId) voidsetProjectId(String projectId) voidstart()toJsonMap(ch.qos.logback.classic.spi.ILoggingEvent event) Convert a logging event into a Map.Methods inherited from class ch.qos.logback.contrib.json.classic.JsonLayout
addCustomDataToJsonMap, addThrowableInfo, getThrowableProxyConverter, isIncludeContextName, isIncludeException, isIncludeFormattedMessage, isIncludeLevel, isIncludeLoggerName, isIncludeMDC, isIncludeMessage, isIncludeThreadName, setIncludeContextName, setIncludeException, setIncludeFormattedMessage, setIncludeLevel, setIncludeLoggerName, setIncludeMDC, setIncludeMessage, setIncludeThreadName, setThrowableProxyConverter, stopMethods inherited from class ch.qos.logback.contrib.json.JsonLayoutBase
add, addMap, addTimestamp, createDateFormat, doLayout, format, formatTimestamp, getContentType, getTimestampFormat, getTimestampFormatTimezoneId, isAppendLineSeparator, isIncludeTimestamp, setAppendLineSeparator, setIncludeTimestamp, setJsonFormatter, setTimestampFormat, setTimestampFormatTimezoneIdMethods inherited from class ch.qos.logback.core.LayoutBase
getContext, getFileFooter, getFileHeader, getPresentationFooter, getPresentationHeader, isStarted, setContext, setFileFooter, setFileHeader, setPresentationFooter, setPresentationHeaderMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getDeclaredOrigin, getStatusManagerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn
-
Constructor Details
-
StackdriverJsonLayout
public StackdriverJsonLayout()
-
-
Method Details
-
getJsonFormatter
public ch.qos.logback.contrib.json.JsonFormatter getJsonFormatter()- Overrides:
getJsonFormatterin classch.qos.logback.contrib.json.JsonLayoutBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
start
public void start()- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
startin classch.qos.logback.contrib.json.classic.JsonLayout
-
toJsonMap
Convert a logging event into a Map.- Overrides:
toJsonMapin classch.qos.logback.contrib.json.classic.JsonLayout- Parameters:
event- the logging event- Returns:
- the map which should get rendered as JSON
-
formatTraceId
Formats traceId to be exact 32 digits.- Parameters:
traceId-- Returns:
- formated tracedId
-
getProjectId
- Returns:
- the project Id
-
setProjectId
- Parameters:
projectId- to set
-
isIncludeTraceId
public boolean isIncludeTraceId()- Returns:
- should trace id be included
-
setIncludeTraceId
public void setIncludeTraceId(boolean includeTraceId) - Parameters:
includeTraceId- sets traceId inclusion
-
isIncludeSpanId
public boolean isIncludeSpanId()- Returns:
- SpanId is included
-
setIncludeSpanId
public void setIncludeSpanId(boolean includeSpanId) - Parameters:
includeSpanId- sets include span id
-
isIncludeExceptionInMessage
public boolean isIncludeExceptionInMessage()- Returns:
- include message in exception
-
setIncludeExceptionInMessage
public void setIncludeExceptionInMessage(boolean includeExceptionInMessage) - Parameters:
includeExceptionInMessage- includeExceptionInMessage
-
getCustomJson
- Returns:
- customJson
-
setCustomJson
- Parameters:
customJson- sets CustomJson Map
-