Skip to content
Xavier F. Gouchet edited this page Sep 4, 2024 · 1 revision

object Logs

An entry point to Datadog Logs feature.

Functions

addAttribute

@JvmOverloads

@JvmStatic

fun addAttribute(key: String, value: Any?, sdkCore: SdkCore = Datadog.getInstance())

Add a custom attribute to all future logs sent by loggers created from the given SDK core.

Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

Parameters
key the key for this attribute
value the attribute value
sdkCore the SdkCore instance to add the attribute to. If not provided, the default instance is used.

enable

@JvmOverloads

@JvmStatic

fun enable(logsConfiguration: LogsConfiguration, sdkCore: SdkCore = Datadog.getInstance())

Enables a Logs feature based on the configuration provided.

Parameters
logsConfiguration Configuration to use for the feature.
sdkCore SDK instance to register feature in. If not provided, default SDK instance will be used.

isEnabled

@JvmOverloads

@JvmStatic

fun isEnabled(sdkCore: SdkCore = Datadog.getInstance()): Boolean

Identify whether a Logs has been enabled for the given SDK instance.

This check is useful in scenarios where more than one component may be responsible for enabling the feature

Return

whether Logs has been enabled

Parameters
sdkCore the SdkCore instance to check against. If not provided, default instance will be checked.

removeAttribute

@JvmOverloads

@JvmStatic

fun removeAttribute(key: String, sdkCore: SdkCore = Datadog.getInstance())

Remove a custom attribute from all future logs sent by loggers created from the given SDK core.

Previous logs won't lose the attribute value associated with this key if they were created prior to this call.

Parameters
key the key of the attribute to remove
sdkCore the SdkCore instance to remove the attribute from. If not provided, the default instance is used.
Clone this wiki locally