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 Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields inherited from class org.apache.logging.log4j.core.layout.AbstractLayout

    configuration, eventCount, footer, header, LOGGER

    Fields inherited from interface org.apache.logging.log4j.core.Layout

    ELEMENT_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    StackdriverLayout(org.apache.logging.log4j.core.config.Configuration configuration, String serviceName, String serviceVersion)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    encode(org.apache.logging.log4j.core.LogEvent event, org.apache.logging.log4j.core.layout.ByteBufferDestination destination)
     
     
    static <B extends StackdriverLayout.Builder<B>>
    B
     
    boolean
     
    byte[]
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StackdriverLayout

      public StackdriverLayout()
    • StackdriverLayout

      public StackdriverLayout(org.apache.logging.log4j.core.config.Configuration configuration, String serviceName, String serviceVersion)
  • Method Details

    • newBuilder

      @PluginBuilderFactory public static <B extends StackdriverLayout.Builder<B>> B newBuilder()
    • toByteArray

      public byte[] toByteArray(org.apache.logging.log4j.core.LogEvent event)
      Specified by:
      toByteArray in interface org.apache.logging.log4j.core.Layout<byte[]>
    • toSerializable

      public byte[] toSerializable(org.apache.logging.log4j.core.LogEvent event)
      Specified by:
      toSerializable in interface org.apache.logging.log4j.core.Layout<byte[]>
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface org.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:
      encode in interface org.apache.logging.log4j.core.layout.Encoder<org.apache.logging.log4j.core.LogEvent>
      Overrides:
      encode in class org.apache.logging.log4j.core.layout.AbstractLayout<byte[]>
    • requiresLocation

      public boolean requiresLocation()
      Specified by:
      requiresLocation in interface org.apache.logging.log4j.core.impl.LocationAware