You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Snapshots are collected only on exceptions that are reported to Application Insights. For ASP.NET and ASP.NET Core applications, the Application Insights SDK automatically reports unhandled exceptions that escape a controller method or endpoint route handler. For other applications, you might need to modify your code to report them. The exception handling code depends on the structure of your application. Here's an example:
Below, is another example using `ILogger`. In this case, when handling an exception, be sure to pass the exception as the first parameter to `LogError`.
// Use the LogError overload with an Exception as the first parameter.
187
+
_logger.LogError(ex, "An error occurred.");
139
188
}
189
+
}
140
190
}
141
191
```
142
192
193
+
> [!NOTE]
194
+
> By default, the Application Insights Logger (`ApplicationInsightsLoggerProvider`) forwards exceptions to the Snapshot Debugger via `TelemetryClient.TrackException`. This behavior is controlled via the `TrackExceptionsAsExceptionTelemetry` property on the `ApplicationInsightsLoggerOptions` class. If you set `TrackExceptionsAsExceptionTelemetry` to `false` when configuring the Application Insights Logger, then the example above will not trigger the Snapshot Debugger. In this case, modify your code to call `TrackException` manually.
0 commit comments