Class OpenTelemetryAppender.Builder<B extends OpenTelemetryAppender.Builder<B>>

java.lang.Object
org.apache.logging.log4j.core.filter.AbstractFilterable.Builder<B>
org.apache.logging.log4j.core.appender.AbstractAppender.Builder<B>
io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender.Builder<B>
All Implemented Interfaces:
org.apache.logging.log4j.core.util.Builder<OpenTelemetryAppender>
Enclosing class:
OpenTelemetryAppender

public static class OpenTelemetryAppender.Builder<B extends OpenTelemetryAppender.Builder<B>> extends org.apache.logging.log4j.core.appender.AbstractAppender.Builder<B> implements org.apache.logging.log4j.core.util.Builder<OpenTelemetryAppender>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    captureCodeAttributes(boolean captureCodeAttributes)
    Sets whether the code attributes (file name, class name, method name and line number) should be set to logs.
    setCaptureContextDataAttributes(String captureContextDataAttributes)
    Configures the ThreadContext attributes that will be copied to logs.
    setCaptureExperimentalAttributes(boolean captureExperimentalAttributes)
    Sets whether experimental attributes should be set to logs.
    setCaptureMapMessageAttributes(boolean captureMapMessageAttributes)
    Sets whether log4j MapMessage attributes should be copied to logs.
    setCaptureMarkerAttribute(boolean captureMarkerAttribute)
    Sets whether the marker attribute should be set to logs.
    setNumLogsCapturedBeforeOtelInstall(int numLogsCapturedBeforeOtelInstall)
    Log telemetry is emitted after the initialization of the OpenTelemetry Logback appender with an OpenTelemetry object.
    setOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry)
    Configures the OpenTelemetry used to append logs.

    Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender.Builder

    getConfiguration, getLayout, getName, getOrCreateLayout, getOrCreateLayout, isIgnoreExceptions, setConfiguration, setIgnoreExceptions, setLayout, setName, withConfiguration, withIgnoreExceptions, withLayout, withName

    Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable.Builder

    asBuilder, getFilter, getPropertyArray, setFilter, setPropertyArray, withFilter

    Methods inherited from class java.lang.Object

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

    • Builder

      public Builder()
  • Method Details

    • setCaptureExperimentalAttributes

      @CanIgnoreReturnValue public B setCaptureExperimentalAttributes(boolean captureExperimentalAttributes)
      Sets whether experimental attributes should be set to logs. These attributes may be changed or removed in the future, so only enable this if you know you do not require attributes filled by this instrumentation to be stable across versions.
    • captureCodeAttributes

      @CanIgnoreReturnValue public B captureCodeAttributes(boolean captureCodeAttributes)
      Sets whether the code attributes (file name, class name, method name and line number) should be set to logs. Enabling these attributes can potentially impact performance (see https://logging.apache.org/log4j/2.x/manual/performance.html#layouts-location).
      Parameters:
      captureCodeAttributes - To enable or disable the code attributes (file name, class name, method name and line number)
    • setCaptureMapMessageAttributes

      @CanIgnoreReturnValue public B setCaptureMapMessageAttributes(boolean captureMapMessageAttributes)
      Sets whether log4j MapMessage attributes should be copied to logs.
    • setCaptureMarkerAttribute

      @CanIgnoreReturnValue public B setCaptureMarkerAttribute(boolean captureMarkerAttribute)
      Sets whether the marker attribute should be set to logs.
      Parameters:
      captureMarkerAttribute - To enable or disable the marker attribute
    • setCaptureContextDataAttributes

      @CanIgnoreReturnValue public B setCaptureContextDataAttributes(String captureContextDataAttributes)
      Configures the ThreadContext attributes that will be copied to logs.
    • setNumLogsCapturedBeforeOtelInstall

      @CanIgnoreReturnValue public B setNumLogsCapturedBeforeOtelInstall(int numLogsCapturedBeforeOtelInstall)
      Log telemetry is emitted after the initialization of the OpenTelemetry Logback appender with an OpenTelemetry object. This setting allows you to modify the size of the cache used to replay the logs that were emitted prior to setting the OpenTelemetry instance into the Logback appender.
    • setOpenTelemetry

      @CanIgnoreReturnValue public B setOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Configures the OpenTelemetry used to append logs.
    • build

      public OpenTelemetryAppender build()
      Specified by:
      build in interface org.apache.logging.log4j.core.util.Builder<B extends OpenTelemetryAppender.Builder<B>>