0

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

emrekara
  • 85
  • 1
  • 9

1 Answers1

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.

source: https://stackoverflow.com/a/65502187/1384539

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