Class StackdriverJsonLayout
- java.lang.Object
-
- org.apache.logging.log4j.core.layout.AbstractLayout<java.lang.String>
-
- org.apache.logging.log4j.core.layout.AbstractStringLayout
-
- org.curioswitch.common.server.framework.logging.StackdriverJsonLayout
-
- All Implemented Interfaces:
org.apache.logging.log4j.core.Layout<java.lang.String>
,org.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>
,org.apache.logging.log4j.core.StringLayout
@Plugin(name="StackdriverJsonLayout", category="Core", elementType="layout", printObject=true) public final class StackdriverJsonLayout extends org.apache.logging.log4j.core.layout.AbstractStringLayout
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StackdriverJsonLayout.Builder<B extends StackdriverJsonLayout.Builder<B>>
static class
StackdriverJsonLayout.JsonLogEventWithAdditionalFields
-
Field Summary
Fields Modifier and Type Field Description protected org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.ResolvableKeyValuePair[]
additionalFields
protected boolean
compact
protected static java.lang.String
COMPACT_EOL
protected boolean
complete
protected static java.lang.String
DEFAULT_EOL
protected java.lang.String
eol
protected boolean
includeNullDelimiter
protected com.fasterxml.jackson.databind.ObjectWriter
objectWriter
-
Fields inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
DEFAULT_STRING_BUILDER_SIZE, MAX_STRING_BUILDER_SIZE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StackdriverJsonLayout
createDefaultLayout()
Creates a JSON Layout using the default settings.protected org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.LogEventWithAdditionalFields
createLogEventWithAdditionalFields(org.apache.logging.log4j.core.LogEvent event, java.util.Map<java.lang.String,java.lang.String> additionalFieldsMap)
java.util.Map<java.lang.String,java.lang.String>
getContentFormat()
java.lang.String
getContentType()
byte[]
getFooter()
Returns appropriate JSON footer.byte[]
getHeader()
Returns appropriate JSON header.static <B extends StackdriverJsonLayout.Builder<B>>
BnewBuilder()
java.lang.String
toSerializable(org.apache.logging.log4j.core.LogEvent event)
Formats aLogEvent
.void
toSerializable(org.apache.logging.log4j.core.LogEvent event, java.io.Writer writer)
protected static boolean
valueNeedsLookup(java.lang.String value)
protected java.lang.Object
wrapLogEvent(org.apache.logging.log4j.core.LogEvent event)
-
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractStringLayout
getBytes, getCharset, getFooterSerializer, getHeaderSerializer, getStringBuilder, getStringBuilderEncoder, serializeToBytes, serializeToString, toByteArray, trimToMaxSize
-
Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
encode, getConfiguration, markEvent
-
-
-
-
Field Detail
-
DEFAULT_EOL
protected static final java.lang.String DEFAULT_EOL
- See Also:
- Constant Field Values
-
COMPACT_EOL
protected static final java.lang.String COMPACT_EOL
- See Also:
- Constant Field Values
-
eol
protected final java.lang.String eol
-
objectWriter
protected final com.fasterxml.jackson.databind.ObjectWriter objectWriter
-
compact
protected final boolean compact
-
complete
protected final boolean complete
-
includeNullDelimiter
protected final boolean includeNullDelimiter
-
additionalFields
protected final org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.ResolvableKeyValuePair[] additionalFields
-
-
Method Detail
-
createDefaultLayout
public static StackdriverJsonLayout createDefaultLayout()
Creates a JSON Layout using the default settings. Useful for testing.- Returns:
- A JSON Layout.
-
newBuilder
@PluginBuilderFactory public static <B extends StackdriverJsonLayout.Builder<B>> B newBuilder()
-
createLogEventWithAdditionalFields
protected org.curioswitch.common.server.framework.logging.AbstractJacksonLayout.LogEventWithAdditionalFields createLogEventWithAdditionalFields(org.apache.logging.log4j.core.LogEvent event, java.util.Map<java.lang.String,java.lang.String> additionalFieldsMap)
-
getContentFormat
public java.util.Map<java.lang.String,java.lang.String> getContentFormat()
- Specified by:
getContentFormat
in interfaceorg.apache.logging.log4j.core.Layout<java.lang.String>
- Overrides:
getContentFormat
in classorg.apache.logging.log4j.core.layout.AbstractLayout<java.lang.String>
-
getContentType
public java.lang.String getContentType()
- Specified by:
getContentType
in interfaceorg.apache.logging.log4j.core.Layout<java.lang.String>
- Overrides:
getContentType
in classorg.apache.logging.log4j.core.layout.AbstractStringLayout
- Returns:
- The content type.
-
getFooter
@Nullable public byte[] getFooter()
Returns appropriate JSON footer.- Specified by:
getFooter
in interfaceorg.apache.logging.log4j.core.Layout<java.lang.String>
- Overrides:
getFooter
in classorg.apache.logging.log4j.core.layout.AbstractStringLayout
- Returns:
- a byte array containing the footer, closing the JSON array.
-
getHeader
@Nullable public byte[] getHeader()
Returns appropriate JSON header.- Specified by:
getHeader
in interfaceorg.apache.logging.log4j.core.Layout<java.lang.String>
- Overrides:
getHeader
in classorg.apache.logging.log4j.core.layout.AbstractStringLayout
- Returns:
- a byte array containing the header, opening the JSON array.
-
toSerializable
public void toSerializable(org.apache.logging.log4j.core.LogEvent event, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
wrapLogEvent
protected java.lang.Object wrapLogEvent(org.apache.logging.log4j.core.LogEvent event)
-
valueNeedsLookup
protected static boolean valueNeedsLookup(java.lang.String value)
-
toSerializable
public java.lang.String toSerializable(org.apache.logging.log4j.core.LogEvent event)
Formats aLogEvent
.- Parameters:
event
- The LogEvent.- Returns:
- The XML representation of the LogEvent.
-
-