0

I'm using Datadog SDK v2.19.1 for my Android app and integrating it with Timber. I followed the guide here, but the logs aren't showing up.

Interestingly, RUM correctly displays user sessions without any issues. However, despite multiple attempts, I can't get the logs to appear. I even tried removing Timber, but the issue persists. Any ideas on what might be wrong?

Please take a look at my integration and let me know if some thing is wrong with it:

  private fun initializeDataDog(environment: Environment) {
    val variantName = BuildConfig.FLAVOR
    val configuration = Configuration.Builder(
      clientToken = BuildConfig.DATA_DOG_CLIENT_TOKEN,
      env = environment.dataDogEnv,
      variant = variantName
    )
      .useSite(DatadogSite.XXX)
      .build()

    // Initialize Datadog with consent granted
    Datadog.initialize(this, configuration, TrackingConsent.GRANTED)

    // Configure RUM (Real User Monitoring)
    val applicationId = BuildConfig.DATA_DOG_APP_ID
    val rumConfig = RumConfiguration.Builder(applicationId)
      .trackUserInteractions()
      .trackLongTasks()
      .build()
    Rum.enable(rumConfig)

    // Enhanced logger configuration
    val logger = Logger.Builder()
      .setName(environment.dataDogeLogName)
      .setNetworkInfoEnabled(true)
      .setLogcatLogsEnabled(true)
      .setRemoteSampleRate(100f)
      .setBundleWithRumEnabled(true)
      .build()

    val logsConfig = LogsConfiguration.Builder().build()
    Logs.enable(logsConfig)

    logger.i("DataDog initialized from Android")
    // Plant the Datadog tree
    Timber.plant(DatadogTree(logger))
  }

Then set the user information:

private fun setUserInfoToDataDog(user: User) {
    try {
      if (!Datadog.isInitialized()) return
      Timber.d("Setting user info to DataDog -- $user")
      Datadog.setUserInfo(
        id = user.id,
        name = user.fullName,
        email = user.email,
        extraInfo = mapOf("phone" to user.phone)
      )
    } catch (throwable: Throwable) {
      Timber.w(throwable, "Can't set user info to DataDog -- $user")
    }
  }

The log look correct:

enter image description here

2
  • Have you able to solve the issue? I am also facing the same issue now. Commented Aug 27 at 3:56
  • Hi Kara, please just use just datadoghq:dd-sdk-android:1.19.3 And Configure similar to the above config. You perhaps need to provide a costcenter, client token, site. etc.. But no need to Logs.enable. Just Configuration.builder, Credentials Object, Datadog init with the details and build a Logger with Builder. You might ste Datadog. setVerbosity(LOG.VERBOSE). Commented Sep 9 at 10:58

1 Answer 1

0

Please just use datadoghq:dd-sdk-android:1.19.3 and configure it similar to the above config. You perhaps need to provide a cost center, client token, site, etc. But no need to Logs.enable. Just use Configuration.builder, Credentials object, Datadog.initialize with the details, and build a Logger with Builder. You might set Datadog.setVerbosity(Log.VERBOSE).

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.