Class OpenTelemetryAppender.Builder<B extends OpenTelemetryAppender.Builder<B>>
- All Implemented Interfaces:
org.apache.logging.log4j.core.util.Builder<OpenTelemetryAppender>
- Enclosing class:
OpenTelemetryAppender
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()setCaptureArguments(boolean captureArguments) Sets whether the arguments should be captured in logs.setCaptureCodeAttributes(boolean captureCodeAttributes) Sets whether the code attributes (file name, class name, method name and line number) should be set to logs.setCaptureContextDataAttributes(String captureContextDataAttributes) Deprecated.setCaptureExperimentalAttributes(boolean captureExperimentalAttributes) Sets whether experimental attributes should be set to logs.setCaptureMapMessageAttributes(boolean captureMapMessageAttributes) Deprecated.UsesetMapMessageAttributes(IncludeExclude)instead.setCaptureMarkerAttribute(boolean captureMarkerAttribute) Sets whether the marker attribute should be set to logs.setCaptureTemplate(boolean captureTemplate) Sets whether the message template should be captured in logs if arguments are provided.setContextDataAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude contextDataAttributes) Configures theThreadContextattributes that will be copied to logs.setContextDataAttributesExcluded(String contextDataAttributesExcluded) Configures the comma-separatedThreadContextattribute key patterns that will not be copied to logs.setContextDataAttributesIncluded(String contextDataAttributesIncluded) Configures the comma-separatedThreadContextattribute key patterns that will be copied to logs.setMapMessageAttributes(io.opentelemetry.instrumentation.api.config.IncludeExclude mapMessageAttributes) Configures the log4jMapMessageattributes that will be copied to logs.setMapMessageAttributesExcluded(String mapMessageAttributesExcluded) Configures the comma-separated log4jMapMessageattribute key patterns that will not be copied to logs.setMapMessageAttributesIncluded(String mapMessageAttributesIncluded) Configures the comma-separated log4jMapMessageattribute key patterns that will be copied to logs.setNumLogsCapturedBeforeOtelInstall(int numLogsCapturedBeforeOtelInstall) Log telemetry is emitted after the initialization of the OpenTelemetry Log4j appender with anOpenTelemetryobject.setOpenTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Configures theOpenTelemetryused 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, withNameMethods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable.Builder
asBuilder, getFilter, getPropertyArray, setFilter, setPropertyArray, withFilter
-
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. -
setCaptureCodeAttributes
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)
-
setMapMessageAttributes
@CanIgnoreReturnValue public B setMapMessageAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude mapMessageAttributes) Configures the log4jMapMessageattributes that will be copied to logs.MapMessagekeys and selector patterns are matched case-sensitively.?matches any single character and*matches any number of characters, including none, soincluded("*")captures everyMapMessageattribute. Excluded patterns take precedence over included patterns. A selector with only excluded patterns captures everyMapMessageattribute that it does not exclude.Only a non-empty selector set here takes precedence over the
mapMessageAttributesIncludedandmapMessageAttributesExcludedsettings, which in turn take precedence over the deprecatedcaptureMapMessageAttributessetting. Anullor empty selector carries no configuration, so it does not disable capture and the next configured source is used instead. NoMapMessageattributes are captured when the selector and the pattern settings are absent or empty andcaptureMapMessageAttributesisfalse, which is also its default.Captured
MapMessageattributes may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes. -
setMapMessageAttributesIncluded
Configures the comma-separated log4jMapMessageattribute key patterns that will be copied to logs.This is the configuration-file form of
setMapMessageAttributes(IncludeExclude)and is ignored when a non-empty selector is set with that method. Patterns use the same case-sensitive glob syntax, where?matches any single character and*matches any number of characters, including none. -
setMapMessageAttributesExcluded
Configures the comma-separated log4jMapMessageattribute key patterns that will not be copied to logs.This is the configuration-file form of
setMapMessageAttributes(IncludeExclude)and is ignored when a non-empty selector is set with that method. Patterns use the same case-sensitive glob syntax, where?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns. -
setCaptureMapMessageAttributes
@Deprecated @CanIgnoreReturnValue public B setCaptureMapMessageAttributes(boolean captureMapMessageAttributes) Deprecated.UsesetMapMessageAttributes(IncludeExclude)instead. May be removed in the next minor release.Sets whether log4jMapMessageattributes should be copied to logs.trueis equivalent to setting a selector that includes"*"withsetMapMessageAttributes(IncludeExclude), andfalseis equivalent to clearing that selector, so the last of these two methods to be called wins. ThecaptureMapMessageAttributesconfiguration-file attribute is only used when no selector and nomapMessageAttributesIncludedormapMessageAttributesExcludedpattern is configured. -
setCaptureMarkerAttribute
Sets whether the marker attribute should be set to logs.- Parameters:
captureMarkerAttribute- To enable or disable the marker attribute
-
setCaptureTemplate
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
Sets whether the arguments should be captured in logs.- Parameters:
captureArguments- whether the arguments should be captured in logs
-
setContextDataAttributes
@CanIgnoreReturnValue public B setContextDataAttributes(@Nullable io.opentelemetry.instrumentation.api.config.IncludeExclude contextDataAttributes) Configures theThreadContextattributes that will be copied to logs.Context data keys and selector patterns are matched case-sensitively.
?matches any single character and*matches any number of characters, including none, soincluded("*")captures every context data attribute. Excluded patterns take precedence over included patterns. A selector with only excluded patterns captures every context data attribute that it does not exclude.Only a non-empty selector set here takes precedence over the
contextDataAttributesIncludedandcontextDataAttributesExcludedsettings, which in turn take precedence over the deprecatedsetCaptureContextDataAttributes(String)setting. Anullor empty selector carries no configuration, so it does not disable capture and the next configured source is used instead. No context data attributes are captured only when every one of these sources is absent or empty.Captured context data attributes may contain sensitive information. Configure included and excluded patterns to limit the data exported as log attributes.
-
setContextDataAttributesIncluded
@CanIgnoreReturnValue public B setContextDataAttributesIncluded(String contextDataAttributesIncluded) Configures the comma-separatedThreadContextattribute key patterns that will be copied to logs.This is the configuration-file form of
setContextDataAttributes(IncludeExclude)and is ignored when a non-empty selector is set with that method. Patterns use the same case-sensitive glob syntax, where?matches any single character and*matches any number of characters, including none. -
setContextDataAttributesExcluded
@CanIgnoreReturnValue public B setContextDataAttributesExcluded(String contextDataAttributesExcluded) Configures the comma-separatedThreadContextattribute key patterns that will not be copied to logs.This is the configuration-file form of
setContextDataAttributes(IncludeExclude)and is ignored when a non-empty selector is set with that method. Patterns use the same case-sensitive glob syntax, where?matches any single character and*matches any number of characters, including none. Excluded patterns take precedence over included patterns. -
setCaptureContextDataAttributes
@Deprecated @CanIgnoreReturnValue public B setCaptureContextDataAttributes(String captureContextDataAttributes) Deprecated.UsesetContextDataAttributes(IncludeExclude)instead. May be removed in the next minor release.Configures theThreadContextattributes that will be copied to logs.This setting does not support glob patterns. A comma-separated list containing only
*captures every context data attribute; otherwise every entry, including one that contains*or?, is matched as a literal context data key.It is ignored when a non-empty selector is set with
setContextDataAttributes(IncludeExclude)or whencontextDataAttributesIncludedorcontextDataAttributesExcludedis configured. -
setNumLogsCapturedBeforeOtelInstall
@CanIgnoreReturnValue public B setNumLogsCapturedBeforeOtelInstall(int numLogsCapturedBeforeOtelInstall) Log telemetry is emitted after the initialization of the OpenTelemetry Log4j appender with anOpenTelemetryobject. 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 OpenTelemetry Log4j appender. -
setOpenTelemetry
Configures theOpenTelemetryused to append logs. -
build
- Specified by:
buildin interfaceorg.apache.logging.log4j.core.util.Builder<B extends OpenTelemetryAppender.Builder<B>>
-
setContextDataAttributes(IncludeExclude)instead.