Logging for Android

Logging for Android involves two different logs:

  • Auto-instrumentor log
  • OneAgent log

Auto-instrumentor log

The auto-instrumentor publishes the debug logs into the console and into the auto-instrumentor log file (the file name starts with AIA and the current date). The log file is stored in the logs directory (root folder is the current working directory). To obtain the debug logs, the auto-instrumentation property DTXLogLevel must be added using the scripts instrument.sh/instrument.cmd.

  • Via Dynatrace Gradle plugin: Add the auto-instrumentation property DTXLogLevel':'debug' through the Dynatrace Gradle plugin property agentProperties to the Dynatrace configuration block in the build.gradle file. When the Android build process is triggered via the Run button from Android Studio, the console logs are displayed in the Gradle Console view. The log file is stored in the <project>/<module>/build/tmp/autoInstrument<build_variant>/logs directory.

  • Via console: Add the auto-instrumentation property DTXLogLevel=debug to the auto-instrumentor Dynatrace.properties file.

OneAgent log

To obtain the debug log for OneAgent from an application when DTXLogLevel=debug is enabled:

  1. Connect the device to your PC (or run the emulator). Check that your device is setup for development.
  2. Launch the command prompt/terminal.
  3. Run adb shell logcat > MyAndroidAppLog.txt For details, see Logcat.
  4. Launch the instrumented app with the new debug flags.

Alternatively:

  1. Connect the device to your PC (or run the emulator). Check that your device is setup for development.
  2. Open the Logcat view in Android Studio (and select device).
  3. Configure the Dynatrace OneAgent logcat filter with the regex (dtx|caa-a).* for the Log Tag field.
  4. Launch the instrumented application using the debug flags.
  5. Extract/print the log to a file.