All Content
Timespan
Create custom logs in Monitor with Power Apps
Image Source: Shutterstock.com
Apr 27, 2023 9:00 PM

Create custom logs in Monitor with Power Apps

External Blog Post

When debugging your apps, do you ever wish you had something similar to the likes of console.log() in JavaScript, to create custom logs in the monitor

When debugging your apps, do you ever wish you had something similar to the likes of console.log() in JavaScript, to create custom logs in the monitor to support?

Well in this blog post I’ll show you how to do just that!

Table of Contents

How to setup trace in PowerApps?

In Power Apps, you can use the console.log() method to print messages to the browser console for debugging purposes. However, if you want to use the trace() method specifically, you can do so by following these steps:

  1. Open the app in edit mode.
  2. Click on the “File” menu and select “App Settings.”
  3. In the “Advanced settings” section, set the “Enable app insights” option to “On.”
  4. Save the app settings and publish the app.

Once app insights are enabled, you can use the trace() method to log messages to the app insights dashboard. Here is an example of how you can use the trace() method:

How to Debugging Power Apps?

Debugging Power Apps can be done using the built-in tools available in the Power Apps Studio. Here are some steps you can follow to debug your Power App:

  1. Use the “Monitor” tool: The Monitor tool allows you to see what is happening in your app as you run it. You can access this tool from the top right-hand corner of the screen. You can use it to monitor data sources, variables, and functions.
  2. Use the “Check Formula” tool: If you suspect that a formula is causing an issue, you can use the “Check Formula” tool to see if there are any errors in the formula. This tool is available in the formula bar, and it will highlight any errors in your formula.
  3. Use breakpoints: Breakpoints allow you to pause the execution of your app at a specific point to examine the state of your app. To set a breakpoint, select the control or function you want to debug and click on the breakpoint button.
  4. Use the “Run to Cursor” tool: This tool allows you to run your app up to a specific point in the code. To use this tool, set a breakpoint at the line of code where you want to stop, and then click on the “Run to Cursor” button.
  5. Use the “Console” tool: The Console tool allows you to log messages and view errors that occur while your app is running. You can access this tool from the bottom of the screen.
  6. Use the “Try-Catch” block: If you want to handle errors in your code, you can use a Try-Catch block. This allows you to catch errors and handle them in a specific way.

By using these tools, you can identify and resolve issues in your Power App.

Mar 29, 2020 — This is just an introduction to add basic custom logging in canvas app and analyse the traces using Application Insights. We can further extend ...

Dec 7, 2021 — This function allows us to add custom logging to the monitor. ... Now you can call the trace just before you submit the form. The will create an ...