AzureWebApp:监控应用程序日志

AzureWebApp: Monitor Application Logs

我正在构建一个 Azure 网络应用程序,如果出现某些意外错误,我希望能够在 Azure 仪表板中弹出它/添加警报。

任何 System.Diagnostics.Trace.TraceError() 条消息都会记录到 ApplicationLog。有没有办法在 Azure 门户中为这些添加 alert/monitoring-graphs?

我认为在 Web 应用程序上配置警报的最灵活选项是启用应用程序洞察力,使 App Insight 成为您的事件源之一:

https://azure.microsoft.com/en-us/documentation/articles/app-insights-search-diagnostic-logs/

设置 Application Insight 后,您可以根据收集到的诊断信息轻松设置任何类型的警报:

https://azure.microsoft.com/en-gb/documentation/articles/app-insights-alerts/

Aram 下面的链接很有帮助。请阅读它们。

要使其正常工作:

  1. ApplicationInsights 添加到您的项目。
  2. (可选)如果您希望日志跟踪 (System.Diagnostics.Trace) 可根据见解进行搜索,请将 Microsoft.ApplicationInsights.TraceListener nuget 添加到您的项目中。
  3. 使用telemetryClient.TrackException()设置服务器异常 当您遇到严重错误时。
  4. 在 Azure 门户上添加警报以在给定时间 window.
  5. 内检查 ServerExceptions