How to: Enable error and performance logging

The Rights Management SDK 4.2 manages diagnosis and performance logs upload through a single device property.

Overview

You can improve your users' experience and troubleshooting by enabling automatic diagnostics and performance logging upload to Microsoft. In order to honor user privacy, you as the app developer, must ask the user to consent before enabling the automatic logging.

You will manager logging control through two properties.

  • Enable logging through the IpcCustomerExperienceDataCollectionEnabled property. The setting is persistent across device resets.

  • Control the logging level through the IpcLogLevel property using the following settings.

    1 - Verbose
    2 - Informational
    3 - Warning
    4 - Error
    5 - Critical

    The default setting is 2. Setting this property is optional for the app.

In each of the example code snippets following, the calling application can set or query the property.

Android
Enable automatic logging
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("IpcCustomerExperienceDataCollectionEnabled", true); 
editor.commit();

Get current logging control flag setting

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Boolean isLogUploadEnabled = preferences.getBoolean("IpcCustomerExperienceDataCollectionEnabled", false);
iOS
Enable automatic logging
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
        [prefs setBool:FALSE forKey:@"IpcCustomerExperienceDataCollectionEnabled ];
        [[NSUserDefaults standardUserDefaults] synchronize];

Get current logging control flag setting

[[NSUserDefaults standardUserDefaults] boolForKey:@"IpcCustomerExperienceDataCollectionEnabled"];

Set log level control

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setInteger:1 forKey:@"IpcLogLevel ];
[[NSUserDefaults standardUserDefaults] synchronize];

Get log level control setting

[[NSUserDefaults standardUserDefaults] boolForKey:@"IpcLogLevel"];
Windows
Enable automatic logging
CustomerExperienceConfiguration::Option = CustomerExperienceOptions::LoggingEnabledNow;

For more information on optional settings, see [CustomerExperienceOptions](customerexperienceoptions.md).

Get current logging control flag setting

CustomerExperienceOptions loggingOption = CustomerExperienceConfiguration::Option;

Note

The Windows code snips above are in C++. For C#, update the syntax with . in place of :: .

Linux / C++ - This SDK has some basic logging that is not as extensive as that of the other platforms. For more information see the Troubleshooting section of the "README.md" at RMS SDK for portable C++.