Application Insights Integration for Sending Logs from Actions

Problem statement

To send the debug prints in Rules, it is possible to use Application Insights. The following code helps to overwrite the console.log function to send the logs to Application Insights. The first rule should have this code, allowing the other rules to send the logs automatically. There is also a related community Q&A.

const appInsights = require('applicationinsights@1.8.8');
  .setAutoCollectConsole(true, true)

This code does not work with Actions. How can Application Insights be integrated to send Action debug logs to this service?


The following code can help send logs from an Action. Each Action has to initialize the appInsights object. Initializing once and having it work in subsequent Actions will not work in Actions as Actions execute in a more isolated environment than Rules. The required version of the Application Insights has to be added for each Action in the dependency section.

let appInsights = require("applicationinsights");
appInsights.defaultClient.trackTrace({message : "This is a test" });

There are some other samples from Microsoft, which may also be helpful.