I have a .NET 5 web application and I have configured application insights. When an error is thrown in my application I can see it in the azure portal, but I don't see any stacktrace
I installed both nuget packages:
In my startup:
services.AddApplicationInsightsTelemetry();
I even tried to configure logging in my program.cs as described here
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.AddApplicationInsights();
logging.AddFilter<ApplicationInsightsLoggerProvider>(string.Empty, LogLevel.Trace);
})
What am I missing?
Okay so I'm still fiddling around with this a bit, but according to docs here "All exceptions handled by application still need to be tracked manually."
Which means that if you write your own exception handlers, you still have to send the exception and stacktrace to application insights yourself.
For example
Either throw the original exception
catch (Exception e)
{
throw;
}
Or send the exception yourself using Ilogger and LogError:
catch (Exception e)
{
_logger.LogError(e, "message here");
return BadRequest(e.ToString());
}