I have an azure function app that uses the microsoft extension logging to application insigths.
I have this code:
public static void Run(IService service, ILogger log, bool throwException, bool addHeartBeat = false)
{
try
{
if (addHeartBeat)
{
var props = new Dictionary<string, object> { {"IsHeartBeat",true } };
log.LogMetric($"Heartbeat: {service.GetType().ToString()}", 0, props);
}
log.LogInformation($"{{logTypeStart}}: {service.GetType()}", logTypeStart);
service.Run(log);
log.LogInformation($"{{logTypeEnd}}: {service.GetType()}", logTypeEnd);
}
catch (Exception ex)
{
log.LogCritical(ex, ex.Message);
if (throwException)
{
throw ex;
}
}
}
I would expect LogCritical to log to the Exceptions but it is added to AppTraces. Can this be changed to log to Exceptions instead?