Test logging messages to the console or files
Log levels
A MobileIron Core administrator can configure Core with the log level for your app. By default, the log level for an app is ACLOGLEVEL_STATUS.
The administrator has a choice of four log levels as shown in the following table:
Debug code for verbose and debug log levels
When the administrator chooses verbose or debug, the administrator also configures a debug code. The debug code is any string. Mobile@Work requires the device user to enter that string before changing the app’s log level. This extra security is because messages logged at verbose and debug log levels may contain sensitive data.
Logging to files
The detailed log data for your AppConnect app, and the AppConnect library contained in the app, is logged to the device’s console. The administrator can choose to write the log data for the app to files on the device in addition to writing the data to the device’s console.
Log file details
Details regarding the log files for each app are:
|
•
|
The log files for each app are saved to the following directory: |
Apps/<app name>/Library/Application Support/AppConnectLogs
|
•
|
The log file for each app is named appConnect.log. |
|
•
|
The log file is at most 1 MB. |
|
•
|
When appconnect.log exceeds 1 MB: |
|
1.
|
It is renamed to appconnect.log.<timestamp>. |
Example: appconnect.log.2015-05-28 15:13:21
|
2.
|
Logging begins in a new file named appconnect.log. |
|
3.
|
If 20 log files already exist, the oldest file is deleted. |
Configuring logging to files
To log data to a file for an AppConnect app, add a key-value pair to the app’s AppConnect app configuration:
|
1.
|
In the Admin Portal, select Policies & Configs > Configurations |
|
2.
|
Select the app configuration for the app and click Edit. |
If the app does not already have an app configuration, select Add New > AppConnect > App Configuration. Enter a name and description for the new app configuration and the app’s bundle ID.
|
3.
|
In App-specific Configurations, click Add+ to add a key-value pair. |
|
4.
|
Enter MI_AC_ENABLE_LOGGING_TO_FILE in the key field. |
The key name is case-sensitive.
|
5.
|
Enter Yes in the value field. |
|
6.
|
Click Add+ to add another key-value pair for the log level. |
|
7.
|
Enter MI_AC_LOG_LEVEL in the key field. |
The key name is case-sensitive.
|
8.
|
Enter one of the following in the value field: error (the default), info, verbose, or debug. |
This value is not case-sensitive.
|
9.
|
If you entered verbose or debug, click Add+ to add another key-value pair. |
|
10.
|
Enter MI_AC_LOG_LEVEL_CODE in the key field. |
The key name is case-sensitive.
|
11.
|
Enter a string for the value. |
The device user will enter this string to activate the verbose or debug log level. You can make up any string. For example, enter 37!8D. For the most security, use a code that is difficult to guess.
The string is case-sensitive.
If you created a new AppConnect app configuration, apply the appropriate labels to it.
Pushing the new log level to the device
Push the change to your device immediately, by doing the following steps on the device:
|
3.
|
Tap Check for Updates. |
|
4.
|
Tap Force Device Check-in. |
If your app is running, it receives the notification for the new configuration. Otherwise, it receives the notification the next time it runs. If the log level is verbose or debug, device user interaction is required to activate the new log level.
Verify that your app correctly handles the new log levels according to your app’s requirements and design.
Activating verbose or debug logging on the device
Log levels verbose and debug require device user interaction. Your app is not notified of these log levels until the device user activates debug mode in Mobile@Work. This activation switch appears in Mobile@Work’s detailed status display for your app. The detailed status display for your app is available after you have launched your app the first time.
The detailed status display for an AppConnect app includes a Debug Mode switch only when you have configured both of the following in the app’s AppConnect app configuration:
|
•
|
a log level of verbose or debug |
In this case, a detailed status display screen for an AppConnect app shows the Debug Mode switch:
Screenshot from Mobile@Work 9.1
|
NOTE:
|
Regarding the keys MI_AC_LOG_LEVEL and MI_AC_LOG_LEVEL_CODE: |
|
•
|
They are not included in the configuration count on an app’s detailed status display. |
|
•
|
They are not included in the configuration your app receives through the AppConnect for iOS API. |
|
•
|
If the administrator makes changes to the AppConnect app configuration that involve only these keys, the AppConnect library does not call the -appConnect:configChangedTo: notification method. |
To activate verbose or debug level logging, do the following on the device:
|
1.
|
Open Mobile@Work on the device. |
|
3.
|
Tap Check For Updates. |
|
4.
|
Tap Force Device Check-In to make sure that Mobile@Work has received the updated log level. |
|
7.
|
Tap the app for which you want verbose or debug level logging. |
Screenshot from Mobile@Work 9.1
Screenshot from Mobile@Work 9.1
Verify that your app correctly handles the verbose and debug levels according to your app’s requirements and design.
Verbose or debug level logging is activated for 24 hours, after which it is automatically deactivated the next time that you launch or switch to the app. However, you can deactivate it any time by tapping Debug Mode again. When deactivated, your app’s log level returns to the default, which is ACLOGLEVEL_STATUS.
Sending log files in an email
You can use Mobile@Work for iOS to send log files to an email address of your choice as a convenient way to view the files. This feature requires Mobile@Work 9.8 for iOS through the most recently released version as supported by MobileIron.
Mobile@Work displays the option to send logs on the app’s status details screen, available in Mobile@Work at Settings > Secure Apps > <app name>. The option is at the bottom of the screen with this text: Send <app name> Logs.
|
NOTE:
|
The displayed option is disabled if the app’s AppConnect authorization status is not authorized. |
When the option is displayed and enabled, tapping it brings up the list of apps able to share the log files, such as email apps, only if all of the following are true:
|
•
|
You included the key-value pairs for the app in its app configuration on MobileIron Core: |
|
-
|
MI_AC_LOG_LEVEL set to debug |
|
-
|
MI_AC_LOG_LEVEL_CODE set to a chosen string |
|
-
|
MI_AC_ENABLE_LOGGING_TO_FILE set to Yes |
|
•
|
In Mobile@Work in Settings > Secure Apps > <app name>, you have turned on Debug Mode and entered the string from MI_AC_LOG_LEVEL_CODE. |