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 DESK Gradle plugin: Add the auto-instrumentation property
DTXLogLevel':'debug'
through the DESK Gradle plugin propertyagentProperties
to the DESK configuration block in thebuild.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-instrumentorDESK.properties
file.
OneAgent log
To obtain the debug log for OneAgent from an application when DTXLogLevel=debug
is enabled:
- Connect the device to your PC (or run the emulator). Check that your device is setup for development.
- Launch the command prompt/terminal.
- Run
adb shell logcat > MyAndroidAppLog.txt
For details, see Logcat. - Launch the instrumented app with the new debug flags.
Alternatively:
- Connect the device to your PC (or run the emulator). Check that your device is setup for development.
- Open the Logcat view in Android Studio (and select device).
- Configure the
DESK OneAgent
logcat filter with the regex(dtx|caa-a).*
for the Log Tag field.
- Launch the instrumented application using the debug flags.
- Copy and paste the log lines into a text file that can be opened with a text editor.
Note:
Debug flags are used explicitly for debugging purposes, not for production. As such, they won't affect how either the app or the instrumentation work. It's generally recommended that these flags be removed when building your PlayStore or production app, because the additional logging can slow down the app.