• Home
  • Platform modules
  • Digital Experience
  • Mobile applications
  • Android
  • Troubleshooting
  • Debug logging for OneAgent

Debug logging for OneAgent

Activate debug logging to troubleshoot OneAgent issues.

Do not enable debug logging for your production apps.

Use debug flags explicitly for debugging purposes, not for production. Remove these flags when building your PlayStore or production app because additional logging might slow down your mobile app or write sensitive information into the device logs.

Activate debug logging mode

You can activate the debug logs via the Dynatrace Android Gradle plugin or OneAgent SDK for Android.

Dynatrace Android Gradle plugin

Enable debug logging via the agentLogging property.

gradle
dynatrace { configurations { sampleConfig { debug { agentLogging true } } } }
gradle
configure<com.dynatrace.tools.android.dsl.DynatraceExtension> { configurations { create("sampleConfig") { debug { agentLogging(true) } } } }

OneAgent SDK

Enable debug logging using the ConfigurationBuilder.withDebugLogging(boolean) method.

java
Dynatrace.startup(this, new DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconURL>") .withDebugLogging(true) .buildConfiguration());
kotlin
Dynatrace.startup(this, DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconURL>") .withDebugLogging(true) .buildConfiguration())

Retrieve logs from the device

OneAgent for Android uses the default log framework from Android. You can use the Logcat window in Android Studio or the command-line logcat tool to view log messages.

To retrieve the Android logs via the Logcat window in Android Studio

  1. Connect your device to your computer or run the emulator.

    Note that your device should be set up for development.

  2. In Android Studio, go to View > Tool Windows > Logcat, and select your device.

  3. Create a filter.

    Follow the steps below if you've enabled the new Logcat tool in Android Studio Dolphin or if you're using Android Studio Electric Eel.

    • Enter tag~:^dtx|^caa in the filter box.

    • If you've adjusted the formatting option, switch to the default Standard View option.

      New Logcat window

    Follow the steps below if you're using the previous version of Logcat.

    • Enter the name of a filter, for example, Dynatrace OneAgent, in the Filter Name box.

    • Enter the ^dtx|^caa regex in the Log tag box.

      Previous version of the Logcat window

  4. Launch the instrumented app by using the debug flags.

  5. Copy and paste the log lines into a text file.