Class OpenTelemetryAppender
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender
- All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.LifeCycle
public class OpenTelemetryAppender
extends ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
Field Summary
Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
name, startedFields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappend(ch.qos.logback.classic.spi.ILoggingEvent event) static voidinstall(io.opentelemetry.api.OpenTelemetry openTelemetry) voidsetCaptureArguments(boolean captureArguments) Sets whether the arguments should be set to logs.voidsetCaptureCodeAttributes(boolean captureCodeAttributes) Sets whether the code attributes (file name, class name, method name and line number) should be set to logs.voidsetCaptureEventName(boolean captureEventName) Sets whether the value of theevent.nameattribute is used as the log event name.voidsetCaptureExperimentalAttributes(boolean captureExperimentalAttributes) Sets whether experimental attributes should be set to logs.voidsetCaptureKeyValuePairAttributes(boolean captureKeyValuePairAttributes) Sets whether the key value pair attributes should be set to logs.voidsetCaptureLoggerContext(boolean captureLoggerContext) Sets whether the logger context properties should be set to logs.voidsetCaptureLogstashAttributes(boolean captureLogstashAttributes) Deprecated.voidsetCaptureLogstashMarkerAttributes(boolean captureLogstashMarkerAttributes) Sets whether the Logstash marker attributes should be captured.voidsetCaptureLogstashStructuredArguments(boolean captureLogstashStructuredArguments) Sets whether the Logstash StructuredArguments should be captured.voidsetCaptureMarkerAttribute(boolean captureMarkerAttribute) Sets whether the marker attribute should be set to logs.voidsetCaptureMdcAttributes(String attributes) Configures theMDCattributes that will be copied to logs.voidsetNumLogsCapturedBeforeOtelInstall(int size) Log telemetry is emitted after the initialization of the OpenTelemetry Logback appender with anOpenTelemetryobject.voidsetOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Configures theOpenTelemetryused to append logs.voidstart()Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, stop, toStringMethods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Constructor Details
-
OpenTelemetryAppender
public OpenTelemetryAppender()
-
-
Method Details
-
install
public static void install(io.opentelemetry.api.OpenTelemetry openTelemetry) -
start
public void start()- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
startin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
append
protected void append(ch.qos.logback.classic.spi.ILoggingEvent event) - Specified by:
appendin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
setCaptureExperimentalAttributes
public void 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. -
setCaptureCodeAttributes
public void setCaptureCodeAttributes(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://logback.qos.ch/manual/layouts.html).- Parameters:
captureCodeAttributes- To enable or disable the code attributes (file name, class name, method name and line number)
-
setCaptureMarkerAttribute
public void setCaptureMarkerAttribute(boolean captureMarkerAttribute) Sets whether the marker attribute should be set to logs.- Parameters:
captureMarkerAttribute- To enable or disable capturing the marker attribute
-
setCaptureKeyValuePairAttributes
public void setCaptureKeyValuePairAttributes(boolean captureKeyValuePairAttributes) Sets whether the key value pair attributes should be set to logs.- Parameters:
captureKeyValuePairAttributes- To enable or disable capturing key value pairs
-
setCaptureLoggerContext
public void setCaptureLoggerContext(boolean captureLoggerContext) Sets whether the logger context properties should be set to logs.- Parameters:
captureLoggerContext- To enable or disable capturing logger context properties
-
setCaptureArguments
public void setCaptureArguments(boolean captureArguments) Sets whether the arguments should be set to logs.- Parameters:
captureArguments- To enable or disable capturing logger arguments
-
setCaptureLogstashAttributes
Deprecated.UsesetCaptureLogstashMarkerAttributes(boolean)instead. This method is deprecated and will be removed in a future release.Sets whether the Logstash attributes should be set to logs.- Parameters:
captureLogstashAttributes- To enable or disable capturing Logstash attributes
-
setCaptureLogstashMarkerAttributes
public void setCaptureLogstashMarkerAttributes(boolean captureLogstashMarkerAttributes) Sets whether the Logstash marker attributes should be captured. -
setCaptureLogstashStructuredArguments
public void setCaptureLogstashStructuredArguments(boolean captureLogstashStructuredArguments) Sets whether the Logstash StructuredArguments should be captured. -
setCaptureMdcAttributes
Configures theMDCattributes that will be copied to logs. -
setCaptureEventName
public void setCaptureEventName(boolean captureEventName) Sets whether the value of theevent.nameattribute is used as the log event name.The
event.nameattribute is captured via any other mechanism supported by this appender, such as whencaptureKeyValuePairAttributesis true.When
captureEventNameis true, then the value of theevent.nameattribute will be used as the log event name, andevent.nameattribute will be removed.- Parameters:
captureEventName- to enable or disable capturing theevent.nameattribute as the log event name
-
setNumLogsCapturedBeforeOtelInstall
public void setNumLogsCapturedBeforeOtelInstall(int size) Log telemetry is emitted after the initialization of the OpenTelemetry Logback appender with anOpenTelemetryobject. This setting allows you to modify the size of the cache used to replay the first logs. -
setOpenTelemetry
public void setOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Configures theOpenTelemetryused to append logs. This MUST be called for the appender to function. Seeinstall(OpenTelemetry)for simple installation option.
-
setCaptureLogstashMarkerAttributes(boolean)instead.