Search code examples
azureazure-web-app-serviceazure-diagnostics

AzureWebApp: Monitor Application Logs


I'm building an Azure web-app and if there are certain unexpected errors, I want to be able to bubble it up in the Azure Dashboard / add alerts.

Any System.Diagnostics.Trace.TraceError() messages are logged to the ApplicationLog. Is there a way to add alert/monitoring-graphs for these in Azure Portal?


Solution

  • Aram's links below really helps. Please read them.

    To Get this working:

    1. Add the ApplicationInsights to your project.
    2. (Optional) If you want log traces (System.Diagnostics.Trace) to be searchable on insights, add Microsoft.ApplicationInsights.TraceListener nuget to your project.
    3. Use telemetryClient.TrackException() to place a server exception when you hit a critical error.
    4. Add an alert on Azure portal to check for ServerExceptions within the given time window.