Log plug-in telemetry to your Application Insights resource
When you opt-in to the Application Insights integration described in the earlier Announcing Monitor model-driven apps using Application Insights (Preview) post, you can also use the new
Microsoft.Xrm.Sdk.PluginTelemetry.ILogger Interface in your plug-in code.
You should use ILogger because it allows telemetry for events that occur within a plug-in to be integrated with the larger scope of data captured with the Application Insights integration. The Application Insights integration will tell you when a plug-in executes, how long it takes to run, and whether it makes any external HTTP requests. But Microsoft cannot add any telemetry within the custom plug-ins that organizations use to extend the service. You must use ILogger to add the telemetry for the custom plug-in code running in your environment.
When you use the ILogger interface, the telemetry is written directly to the same Application Insights resource that you choose to have your Dataverse and model-driven app telemetry exported to. The plug-in telemetry you write is never sent to Microsoft. If you use ILogger in a plug-in that is not running in an environment using the Application Insights integration, nothing happens.
The ITracingService available for plug-ins has never been intended to provide a telemetry solution. It is intended to facilitate debugging runtime errors. With ILogger, you can capture true telemetry data that will persist for as long as you choose to retain it. This data will allow you to capture metrics over time and use Application Insights capabilities to view and analyze the data. You can configure alerts to be sent when specified conditions occur.
To learn more, go to Write Telemetry to your Application Insights resource using ILogger (Preview).