Logging to application insight when there is an exception in an Azure function project but only exception message is logged, I want to add custom property
Asked
Active
Viewed 855 times
0
-
Do you track the exception manually? – Peter Bons Apr 22 '22 at 08:42
-
@PeterBons no it logs automatically – emrekara Apr 22 '22 at 08:56
1 Answers
0
catch(InvalidStatusCodeException status_ex)
{
log.LogError(status_ex, "Invalid Status code for request: '{ApiUrl}', received code: {ReceivedStatusCode}", status_ex.ApiUrl, status_ex.ReceivedStatusCode);
}
The above log will add ApiUrl and ReceivedStatusCode as custom properties in application insights log.

Thiago Custodio
- 17,332
- 6
- 45
- 90