Menu
Amazon Mobile Analytics
User Guide

Enabling SDK Logging

A very useful tool for troubleshooting issues with Mobile Analytics is a log of the interactions between your app and the Mobile SDK. How you switch on SDK logging depends on which SDK you use.

Enabling Logging for iOS Apps

To turn on verbose logging of the AWS Mobile SDK for iOS, call the following line in the - application:didFinishLaunchingWithOptions: application delegate.

Swift:

Copy
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { ... AWSLogger.defaultLogger().logLevel = .Verbose ... return true } }

Objective-C:

Copy
#import <AWSCore/AWSCore.h> @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose; ... return YES; } @end

For more information, see Logging in the AWS Mobile SDK iOS Developer Guide.

Enabling Logging for Android Apps

To turn on verbose logging of the AWS Mobile SDK for Android, include the following line of code in the onCreate method of the main activity of the app.

Copy
java.util.logging.Logger.getLogger("com.amazonaws").setLevel(Level.ALL);

Enabling Logging for JavaScript Apps

The Amazon Mobile Analytics SDK for JavaScript enables logging by passing a Logger object to the AMA.Client.Options object. The Logger object uses Javascript-style log levels with a separate function for each logging level. Because the console object adheres to the logger interface (.log, .error, .info, .debug) you can pass it directly to the Manager constructor.

Copy
var options = { appId : MOBILE_ANALYTICS_APP_ID, //Required e.g. 'c5d69c75a92646b8953126437d92c0' platform : DEVICE_PLATFORM, //Optional valid values: 'Android', 'iPhoneOS' logger : console //Specifying logger }; mobileAnalyticsClient = new AMA.Manager(options);

For more information, see the Amazon Mobile Analytics SDK for JavaScript.

Enabling Logging for Unity Apps

For information on how to switch on logging in apps using the AWS Mobile SDK for Unity, see Set Logging Information in the AWS Mobile SDK Unity Developer Guide.

Enabling Logging for Xamarin Apps

For information on how to switch on logging in apps using the AWS Mobile SDK for Xamarin, see Set Logging in the AWS Mobile SDK Xamarin Developer Guide.