The Console desktop tool enables you to capture console output, the same as what you currently see in Qt Creator, from an AppStudio app using a desktop tool. As with the Qt Creator console, the Console tool can be used with an app running on the same machine, but it can also receive output from another device on the same network. This is ideal for capturing console output from your iOS or Android device and viewing it on your desktop.
Enable the Console tool
When you start AppStudio for ArcGIS version 1.2 or later, you'll see the Console icon in the toolbar at the top of the app. This opens the Console tool.
Access to this tool does not require you to sign in.
Aside from the host computer's details, this page at first appears empty, as an app needs to be directed to a console before information will be outputted to it. This can only be done in an AppStudio app that has logging enabled.
Enable logging in Player
For in-development or enterprise apps, Player has built-in compatibility with the console. To enable logging in Player, click the Settings menu and click the Diagnostics tab. Click the Enable Logging toggle key to display the options for the logging mode.
The following are the two logging modes available:
- Local File—Saves the console messages locally, with the option to email the file when finished. On Windows, the log file is saved to C:/Users/YourName/ArcGIS/AppStudio/Logs/.
- Remote Console—Gives you three different methods to set the console IP address. Make sure, before making any selection, that the AppStudio console you want to output to has been started. If it hasn't, you won't be able to connect to it.
If you select Remote Console, you must choose how to connect to your device.
- Select AppStudio Console allows you to choose a currently running AppStudio console from Player to complete the connection.
- Scan QR Code is useful when running apps in Player on mobile devices. Before scanning the code, select the IP address. Since the system running the AppStudio console may have multiple IP addresses assigned to it, the QR code will be generated for the address selected from the drop-down list and appear beside it. Clicking this QR code displays a larger version, which is useful if the device is unable to scan the smaller code. Scan the generated QR code at either size to complete the connection.
- Enter IP Address opens a new page where you manually enter the IP address and port; for example, syslog://10.112.25.174:514. Press Enter on your keyboard to connect to the console.
With all of these methods, all actions you perform in Player will send messages to the console on your selected desktop.
Log messages with Console
Once Player has been connected to the Console tool, the Log output locations field automatically populates with the connected device's details.
The console on your selected desktop will immediately display diagnostic information from both Player and the app running in it. Messages from Player and the app are distinguished in the App column. The console will receive information until you either disable logging in Player or click Stop in the console.
Log to other consoles online
The Console tool uses the syslog protocol, a widely supported and compatible means of logging information within a network or online. This means that the logging capabilities of Player, and console-supporting apps, can be used to send messages to other syslog consoles such as Loggly.
To do this, manually enter the URL or IP address of your syslog location into the Log output location text box. You may also need to provide user ID information. Enter this in the User data text box. To learn more about user ID information and Loggly, refer to Loggly's documentation.
Save logged console messages to a file
The Console tool can also export the messages received to a log file that can be referred to later or sent to others. To do this, click the Save button in the console either during or after logging. A dialog box appears where you choose the file destination and name, and save the results as a .log file.
Add console compatibility to your app
You can add the ability to output console messages to your own app. At a minimum, the following line of code will allow your app to output console messages to an external log file in the default location on the device:
AppFramework.logging.enabled = true;
To ensure this file can be created when running your app on an Android device, in Settings, on the Capabilities tab, confirm that External Storage is selected.
For more detailed examples of how logging can be implemented, see the enterprise templates of Player and Survey123 supplied with AppStudio.