Class 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
-
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.voidsetCaptureExperimentalAttributes(boolean captureExperimentalAttributes) Sets whether experimental attributes should be set to logs.voidsetCaptureKeyValuePairAttributes(boolean captureKeyValuePairAttributes) Deprecated.voidsetCaptureLoggerContext(boolean captureLoggerContext) Deprecated.UsesetLoggerContextAttributesIncluded(String)andsetLoggerContextAttributesExcluded(String), orsetLoggerContextAttributes(IncludeExclude), which select logger context property keys by glob pattern.voidsetCaptureLogstashMarkerAttributes(boolean captureLogstashMarkerAttributes) Deprecated.UsesetLogstashMarkerAttributesIncluded(String)andsetLogstashMarkerAttributesExcluded(String), orsetLogstashMarkerAttributes(IncludeExclude), which select Logstash marker keys by glob pattern.voidsetCaptureLogstashStructuredArguments(boolean captureLogstashStructuredArguments) Deprecated.UsesetLogstashStructuredArgumentAttributesIncluded(String)andsetLogstashStructuredArgumentAttributesExcluded(String), orsetLogstashStructuredArgumentAttributes(IncludeExclude), which select Logstash structured argument keys by glob pattern.voidsetCaptureMarkerAttribute(boolean captureMarkerAttribute) Sets whether the marker attribute should be set to logs.voidsetCaptureMdcAttributes(String captureMdcAttributes) Deprecated.UsesetMdcAttributesIncluded(String)andsetMdcAttributesExcluded(String), orsetMdcAttributes(IncludeExclude), which select MDC keys by glob pattern.voidsetCaptureTemplate(boolean captureTemplate) Sets whether the message template should be captured in logs if arguments are provided.voidsetKeyValuePairAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude keyValuePairAttributes) Configures the key value pair attributes that will be copied to logs.voidsetKeyValuePairAttributesExcluded(String keyValuePairAttributesExcluded) Configures the comma-separated key value pair key patterns that will not be copied to logs.voidsetKeyValuePairAttributesIncluded(String keyValuePairAttributesIncluded) Configures the comma-separated key value pair key patterns that will be copied to logs.voidsetLoggerContextAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude loggerContextAttributes) Configures the logger context properties that will be copied to logs.voidsetLoggerContextAttributesExcluded(String loggerContextAttributesExcluded) Configures the comma-separated logger context property key patterns that will not be copied to logs.voidsetLoggerContextAttributesIncluded(String loggerContextAttributesIncluded) Configures the comma-separated logger context property key patterns that will be copied to logs.voidsetLogstashMarkerAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude logstashMarkerAttributes) Configures the Logstash marker attributes that will be copied to logs.voidsetLogstashMarkerAttributesExcluded(String logstashMarkerAttributesExcluded) Configures the comma-separated Logstash marker key patterns that will not be copied to logs.voidsetLogstashMarkerAttributesIncluded(String logstashMarkerAttributesIncluded) Configures the comma-separated Logstash marker key patterns that will be copied to logs.voidsetLogstashStructuredArgumentAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude logstashStructuredArgumentAttributes) Configures the Logstash structured argument attributes that will be copied to logs.voidsetLogstashStructuredArgumentAttributesExcluded(String logstashStructuredArgumentAttributesExcluded) Configures the comma-separated Logstash structured argument key patterns that will not be copied to logs.voidsetLogstashStructuredArgumentAttributesIncluded(String logstashStructuredArgumentAttributesIncluded) Configures the comma-separated Logstash structured argument key patterns that will be copied to logs.voidsetMdcAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude mdcAttributes) Configures theMDCattributes that will be copied to logs.voidsetMdcAttributesExcluded(String mdcAttributesExcluded) Configures the comma-separatedMDCkey patterns that will not be copied to logs.voidsetMdcAttributesIncluded(String mdcAttributesIncluded) Configures the comma-separatedMDCkey patterns 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 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
Deprecated.UsesetKeyValuePairAttributesIncluded(String)andsetKeyValuePairAttributesExcluded(String), orsetKeyValuePairAttributes(IncludeExclude), which select key value pair keys by glob pattern. May be removed in the next minor release.Sets whether the key value pair attributes should be set to logs.This setter backs the
captureKeyValuePairAttributeselement inlogback.xml.- Parameters:
captureKeyValuePairAttributes- To enable or disable capturing key value pairs
-
setKeyValuePairAttributes
public void setKeyValuePairAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude keyValuePairAttributes) Configures the key value pair attributes that will be copied to logs.Key value pair keys and selector patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all key value pair attributes. Excluded patterns take precedence over included patterns, so a selector with only excluded patterns captures every key value pair attribute that it does not exclude.A
nullor empty selector leaves this appender without a programmatic selector, in which case the key value pair attributes are selected bysetKeyValuePairAttributesIncluded(String)andsetKeyValuePairAttributesExcluded(String). When these are also absent or empty, the deprecatedsetCaptureKeyValuePairAttributes(boolean)setting controls whether all key value pair attributes are captured. Only a non-empty selector configured with this method takes precedence over the other settings.Captured key value pair attributes may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes.
-
setKeyValuePairAttributesIncluded
Configures the comma-separated key value pair key patterns that will be copied to logs.This setter backs the
keyValuePairAttributesIncludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetKeyValuePairAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureKeyValuePairAttributes(boolean).Key value pair keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all key value pair attributes. Excluded patterns take precedence over included patterns. -
setKeyValuePairAttributesExcluded
Configures the comma-separated key value pair key patterns that will not be copied to logs.This setter backs the
keyValuePairAttributesExcludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetKeyValuePairAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureKeyValuePairAttributes(boolean).Key value pair keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns, so configuring only excluded patterns captures every key value pair attribute that they do not exclude. -
setCaptureLoggerContext
Deprecated.UsesetLoggerContextAttributesIncluded(String)andsetLoggerContextAttributesExcluded(String), orsetLoggerContextAttributes(IncludeExclude), which select logger context property keys by glob pattern. May be removed in the next minor release.Sets whether the logger context properties should be set to logs.- Parameters:
captureLoggerContext- To enable or disable capturing logger context properties
-
setLoggerContextAttributes
public void setLoggerContextAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude loggerContextAttributes) Configures the logger context properties that will be copied to logs.Logger context property keys and selector patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all logger context properties. Excluded patterns take precedence over included patterns, so a selector with only excluded patterns captures every logger context property that it does not exclude.A
nullor empty selector leaves this appender without a programmatic selector, in which case the logger context properties are selected bysetLoggerContextAttributesIncluded(String)andsetLoggerContextAttributesExcluded(String), and then by the deprecatedsetCaptureLoggerContext(boolean). No logger context properties are captured when all of these are absent or empty.Captured logger context properties may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes.
-
setLoggerContextAttributesIncluded
Configures the comma-separated logger context property key patterns that will be copied to logs.This setter backs the
loggerContextAttributesIncludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetLoggerContextAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureLoggerContext(boolean).Logger context property keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all logger context properties. Excluded patterns take precedence over included patterns. -
setLoggerContextAttributesExcluded
Configures the comma-separated logger context property key patterns that will not be copied to logs.This setter backs the
loggerContextAttributesExcludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetLoggerContextAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureLoggerContext(boolean).Logger context property keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns, so configuring only excluded patterns captures every logger context property that they do not exclude. -
setCaptureTemplate
public void setCaptureTemplate(boolean captureTemplate) Sets whether the message template should be captured in logs if arguments are provided.- Parameters:
captureTemplate- whether the message template should be captured in logs if arguments are provided
-
setCaptureArguments
public void setCaptureArguments(boolean captureArguments) Sets whether the arguments should be set to logs.- Parameters:
captureArguments- To enable or disable capturing logger arguments
-
setCaptureLogstashMarkerAttributes
Deprecated.UsesetLogstashMarkerAttributesIncluded(String)andsetLogstashMarkerAttributesExcluded(String), orsetLogstashMarkerAttributes(IncludeExclude), which select Logstash marker keys by glob pattern. May be removed in the next minor release.Sets whether the Logstash marker attributes should be captured.- Parameters:
captureLogstashMarkerAttributes- To enable or disable capturing Logstash marker attributes
-
setLogstashMarkerAttributes
public void setLogstashMarkerAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude logstashMarkerAttributes) Configures the Logstash marker attributes that will be copied to logs.Logstash marker keys and selector patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all Logstash marker attributes. Excluded patterns take precedence over included patterns, so a selector with only excluded patterns captures every Logstash marker attribute that it does not exclude.A
nullor empty selector leaves this appender without a programmatic selector, in which case the Logstash marker attributes are selected bysetLogstashMarkerAttributesIncluded(String)andsetLogstashMarkerAttributesExcluded(String), and then by the deprecatedsetCaptureLogstashMarkerAttributes(boolean). No Logstash marker attributes are captured when all of these are absent or empty.Captured Logstash marker attributes may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes.
-
setLogstashMarkerAttributesIncluded
Configures the comma-separated Logstash marker key patterns that will be copied to logs.This setter backs the
logstashMarkerAttributesIncludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetLogstashMarkerAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureLogstashMarkerAttributes(boolean).Logstash marker keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all Logstash marker attributes. Excluded patterns take precedence over included patterns. -
setLogstashMarkerAttributesExcluded
Configures the comma-separated Logstash marker key patterns that will not be copied to logs.This setter backs the
logstashMarkerAttributesExcludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetLogstashMarkerAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureLogstashMarkerAttributes(boolean).Logstash marker keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns, so configuring only excluded patterns captures every Logstash marker attribute that they do not exclude. -
setCaptureLogstashStructuredArguments
@Deprecated public void setCaptureLogstashStructuredArguments(boolean captureLogstashStructuredArguments) Deprecated.UsesetLogstashStructuredArgumentAttributesIncluded(String)andsetLogstashStructuredArgumentAttributesExcluded(String), orsetLogstashStructuredArgumentAttributes(IncludeExclude), which select Logstash structured argument keys by glob pattern. May be removed in the next minor release.Sets whether the Logstash StructuredArguments should be captured. -
setLogstashStructuredArgumentAttributes
public void setLogstashStructuredArgumentAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude logstashStructuredArgumentAttributes) Configures the Logstash structured argument attributes that will be copied to logs.Logstash structured argument keys and selector patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all Logstash structured argument attributes. Excluded patterns take precedence over included patterns, so a selector with only excluded patterns captures every Logstash structured argument attribute that it does not exclude.A
nullor empty selector leaves this appender without a programmatic selector, in which case the Logstash structured argument attributes are selected bysetLogstashStructuredArgumentAttributesIncluded(String)andsetLogstashStructuredArgumentAttributesExcluded(String), and then by the deprecatedsetCaptureLogstashStructuredArguments(boolean). No Logstash structured argument attributes are captured when all of these are absent or empty.Captured Logstash structured argument attributes may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes.
-
setLogstashStructuredArgumentAttributesIncluded
public void setLogstashStructuredArgumentAttributesIncluded(@Nullable String logstashStructuredArgumentAttributesIncluded) Configures the comma-separated Logstash structured argument key patterns that will be copied to logs.This setter backs the
logstashStructuredArgumentAttributesIncludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetLogstashStructuredArgumentAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureLogstashStructuredArguments(boolean).Logstash structured argument keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all Logstash structured argument attributes. Excluded patterns take precedence over included patterns. -
setLogstashStructuredArgumentAttributesExcluded
public void setLogstashStructuredArgumentAttributesExcluded(@Nullable String logstashStructuredArgumentAttributesExcluded) Configures the comma-separated Logstash structured argument key patterns that will not be copied to logs.This setter backs the
logstashStructuredArgumentAttributesExcludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetLogstashStructuredArgumentAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureLogstashStructuredArguments(boolean).Logstash structured argument keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns, so configuring only excluded patterns captures every Logstash structured argument attribute that they do not exclude. -
setMdcAttributes
public void setMdcAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude mdcAttributes) Configures theMDCattributes that will be copied to logs.MDC keys and selector patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all MDC attributes. Excluded patterns take precedence over included patterns, so a selector with only excluded patterns captures every MDC attribute that it does not exclude.A
nullor empty selector leaves this appender without a programmatic selector, in which case the MDC attributes are selected bysetMdcAttributesIncluded(String)andsetMdcAttributesExcluded(String), or, when those are absent or empty too, by the deprecatedsetCaptureMdcAttributes(String). No MDC attributes are captured when all of these are absent or empty. Only a non-empty selector configured with this method takes precedence over the other settings.Captured MDC attributes may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes.
-
setMdcAttributesIncluded
Configures the comma-separatedMDCkey patterns that will be copied to logs.This setter backs the
mdcAttributesIncludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetMdcAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureMdcAttributes(String).MDC keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, so*captures all MDC attributes. Excluded patterns take precedence over included patterns. -
setMdcAttributesExcluded
Configures the comma-separatedMDCkey patterns that will not be copied to logs.This setter backs the
mdcAttributesExcludedelement inlogback.xml. It is ignored when a non-empty selector is configured withsetMdcAttributes(IncludeExclude), and it takes precedence over the deprecatedsetCaptureMdcAttributes(String).MDC keys and patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns, so configuring only excluded patterns captures every MDC attribute that they do not exclude. -
setCaptureMdcAttributes
Deprecated.UsesetMdcAttributesIncluded(String)andsetMdcAttributesExcluded(String), orsetMdcAttributes(IncludeExclude), which select MDC keys by glob pattern. May be removed in the next minor release.Configures the comma-separatedMDCkeys that will be copied to logs.Keys are matched by exact, case-sensitive equality, except that the single value
*captures all MDC attributes. This setting is ignored when a non-empty selector is configured withsetMdcAttributes(IncludeExclude),setMdcAttributesIncluded(String)orsetMdcAttributesExcluded(String). -
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.
-
setKeyValuePairAttributesIncluded(String)andsetKeyValuePairAttributesExcluded(String), orsetKeyValuePairAttributes(IncludeExclude), which select key value pair keys by glob pattern.