Package io.camunda.zeebe.util.logging
Class StackdriverLayout
java.lang.Object
org.apache.logging.log4j.core.layout.AbstractLayout<byte[]>
io.camunda.zeebe.util.logging.StackdriverLayout
- All Implemented Interfaces:
org.apache.logging.log4j.core.impl.LocationAware,org.apache.logging.log4j.core.Layout<byte[]>,org.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>
@Plugin(name="StackdriverLayout",
category="Core",
elementType="layout")
public final class StackdriverLayout
extends org.apache.logging.log4j.core.layout.AbstractLayout<byte[]>
implements org.apache.logging.log4j.core.impl.LocationAware
Stackdriver JSON layout as described here:
https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
https://cloud.google.com/error-reporting/docs/formatting-error-messages
https://cloud.google.com/logging/docs/agent/configuration#special-fields
The layout produces log output which fully integrates with Google's ErrorReporting, as well as properly unwrapping the context map to allow adding ad-hoc fields such as the trace and spanId to integrated with Cloud Trace.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classStackdriverLayout.Builder<B extends StackdriverLayout.Builder<B>> -
Field Summary
Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
configuration, eventCount, footer, header, LOGGERFields inherited from interface org.apache.logging.log4j.core.Layout
ELEMENT_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionStackdriverLayout(org.apache.logging.log4j.core.config.Configuration configuration, String serviceName, String serviceVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoidencode(org.apache.logging.log4j.core.LogEvent event, org.apache.logging.log4j.core.layout.ByteBufferDestination destination) static <B extends StackdriverLayout.Builder<B>>
Bbooleanbyte[]toByteArray(org.apache.logging.log4j.core.LogEvent event) byte[]toSerializable(org.apache.logging.log4j.core.LogEvent event) Methods inherited from class org.apache.logging.log4j.core.layout.AbstractLayout
getConfiguration, getContentFormat, getFooter, getHeader, markEvent
-
Constructor Details
-
StackdriverLayout
public StackdriverLayout() -
StackdriverLayout
-
-
Method Details
-
newBuilder
-
toByteArray
public byte[] toByteArray(org.apache.logging.log4j.core.LogEvent event) - Specified by:
toByteArrayin interfaceorg.apache.logging.log4j.core.Layout<byte[]>
-
toSerializable
public byte[] toSerializable(org.apache.logging.log4j.core.LogEvent event) - Specified by:
toSerializablein interfaceorg.apache.logging.log4j.core.Layout<byte[]>
-
getContentType
- Specified by:
getContentTypein interfaceorg.apache.logging.log4j.core.Layout<byte[]>
-
encode
public void encode(org.apache.logging.log4j.core.LogEvent event, org.apache.logging.log4j.core.layout.ByteBufferDestination destination) - Specified by:
encodein interfaceorg.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>- Overrides:
encodein classorg.apache.logging.log4j.core.layout.AbstractLayout<byte[]>
-
requiresLocation
public boolean requiresLocation()- Specified by:
requiresLocationin interfaceorg.apache.logging.log4j.core.impl.LocationAware
-