Monitor Canvas App logs in PowerApps Monitor and Application Insights

In my last post, “LOG TELEMETRY FOR CANVAS APP USING APPLICATION INSIGHTS” we discussed how to log or view canvas application telemetry in Azure Application Insights. Now, we are going to discuss how to view logs in PowerApps Monitor and Application Insights.

PowerApps log can be viewed in built into PowerApps Monitor or Azure Application Insights (App Insights).

PowerApps Monitor

Using built in PowerApps monitor, we can trace events , custom logs and any user action. This tool can be used for development and even published app. To do that

  1. Go to PowerApps
  2. Open any app
  3. Click “Advanced Tools” on the left navigation menu
  4.  This opens a new browser and monitoring starts automatically. This includes User Action, Function, network and many more.
  5.  Click on the any row to see more details
  6.  For published app,
    1. On the left pane, select Apps
    2. Select an app from the list
    3. Select Monitor from the menu. Or, you can select More Commands (…), and then select Monitor
  7. Here is the Microsoft Article for debugging

In different application, we do logging differently. In Canvas app we are using function called Trace.

Trace Function in Canvas App

Trace is an optional expression that can be used to provide additional information (Custom logging) along with built in event tracing

Syntax

Message – Required. The information (Custom Logging) to be traced
Trace_severity – Optional. The severity level of the Trace recorded in Application Insights. Options are Information, Warning or Error.
Custom_record – Optional. A record containing custom data that will be recorded in Application Insights

Custom record – JSON format that contains any custom data or logging information

Example

  • Trace(“Contacts Gallary Loaded”,TraceSeverity.Information)
  • Trace(“Contacts Gallary Loaded”,TraceSeverity.Information, {Screen: App.ActiveScreen.Name, Control: “OnStart”})
  • Trace(“Contacts Gallary Loaded”,TraceSeverity.Error, {Screen: App.ActiveScreen.Name, Control: “Save Data”})

View the logs in Application Insights

When the app insights are connected to a PowerApps Canvas Screen it allows to capture telemetry such as Screen Views, Duration, Custom Events and Errors. If implemented correctly, this telemetry is useful to understand how users are using the app.

Publish the app and do some actions, so that system can collect some information. Now, new events generated in App Insights. These events will be displayed in the session details, or you can directly query them from the Logs.

From Azure Application Insights, we can create an alert to automatically notify the user or admin if errors get logged, or if there was a sudden increase in errors experienced in the app.

  1. Go to https://portal.azure.com
  2. Open the App insights that we created and linked to the canvas app
  3. Click “Logs” on the left navigation
  4.  Log queries are very powerful and we can use them to join multiple tables, aggregate large amounts of data and perform complex operations
  5. Here is my query to get trace logs
  6. Sample query
  7. traces
    | where message contains “started” or message contains “loaded” or message contains “Updated”
    | limit 50
    | order by timestamp desc
  8. Run the query and we can even save the query for later use
  9. We can built Power BI report for deep analysis

I hope this helps you. Happy Development!

Leave a Reply

Your email address will not be published.