I am having a Functions App (version 2.0) and trying to log stack trace of an exception.
try
{
processedOrder = await orderProcessingService.ProcessOrder(order);
}
catch (Exception ex)
{
log.LogError(ex, $"Error processing order: {order.Id}");
}
This only logs the message in App Insights but nothing about the exception object passed.
Am I doing this right?
If I do
log.LogError(ex, $"Error processing order: {order.Id}", ex)
then I do get to see the exception message but not the stack trace.
Apart from logging the error, you need to explicitly track the exception using telemetry client to get the exception details. I implemented ExceptionLogger in web API 2.0 to send the exception details to app-insights using track exception method.
var telemetry = new TelemetryClient();
...
try
{ ...
}
catch (Exception ex)
{
telemetry.TrackException(ex, properties, measurements);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With