The AWS SDK for Android includes logging via the Apache Commons
logging project. The SDK makes use of this library and its link to
Android LogCat to provide logging for internal operations of the SDK.
By default, only informational, warning, and error messages will be
visible by LogCat. This article discusses how to tune the
visibility of log messages.
Note: The KinesisRecorder and AmazonMobileAnalytics libraries use LogCat directly.
If you should choose to disable all logging in the AWS SDK for Android, you simply need to insert the following piece of code in your Android app:
java.util.logging.Logger.getLogger("com.amazonaws").setLevel(java.util.logging.Level.OFF); |
When using the AWS SDK for Android, you may need to inspect the request and basic response information from AWS services. To do this, you can enable request logging, but you must first add the following code to your Android app:
java.util.logging.Logger.getLogger("com.amazonaws").setLevel(java.util.logging.Level.FINEST); |
Note: Make sure you remove this code before exporting your app for use on Android devices as it will effect the performance of your app.
Additionally, you will need to execute the following ADB shell command to enable LogCat to display these new log messages:
adb shell setprop log.tag.com.amazonaws.request DEBUG |
Note: This command requires that you have a running emulator or connected Android device; it will persist only until the emulator/device restarts.
If you need to examine the raw HTTP requests and responses (either at the request of AWS support or for your own interests), you can enable apache HTTP client logging. To enable this logging, you must first add the following code to your app:
java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.FINEST); |
Note: Make sure you remove this code before exporting your app for use on Android devices as it will effect the performance of your app.
Additionally, you will need to execute the following ADB shell commands to enable LogCat to display these new log messages:
adb shell setprop log.tag.org.apache.http.headers VERBOSE adb shell setprop log.tag.org.apache.http.wire VERBOSE |
Note: This command requires that you have a running emulator or connected Android device; it will persist only until the emulator/device restarts.
The code and commands provided in this article demonstrate how to modify the logging of Android apps using the AWS SDK for Android. You can download the SDK and review the documentation here.
Please feel free to ask questions or provide comments in the Mobile Development Forum.