Debug logging for OneAgent
Note: Debug flags are used explicitly for debugging purposes, not for production. They don't affect the working of the app or the instrumentation. We recommend that these flags be removed when building your PlayStore or production app because the additional logging can slow down the app or print sensitive data.
Activate debug logging mode
You can either activate the debug logs via the Dynatrace Android Gradle plugin or the OneAgent SDK.
Dynatrace Android Gradle plugin
You can activate debug logging via the agentLogging
property.
dynatrace {
configurations {
sampleConfig {
debug {
agentLogging true
}
}
}
}
configure<com.dynatrace.tools.android.dsl.DynatraceExtension> {
configurations {
create("sampleConfig") {
debug {
agentLogging(true)
}
}
}
}
OneAgent SDK
You can activate debug logging with the ConfigurationBuilder.withDebugLogging(boolean)
method.
Dynatrace.startup(this, new DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconURL>")
.withDebugLogging(true)
.buildConfiguration());
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 monitor from Android Studio or the logcat command-line tool to view these log lines. The following steps must be performed to retrieve the Android logs via Logcat view in Android Studio:
-
Connect the device to your PC (or run the emulator). Check that your device is set up for development.
-
Open the Logcat view in Android Studio and select the device.
-
Configure the
Dynatrace OneAgent
logcat filter with the regex(dtx|caa-a).*
for the Log Tag field. -
Launch the instrumented app by using the debug flags.
-
Copy and paste the log lines into a text file that can be opened with a text editor.