I have an Azure Function V3 (.net core). I'm using ILogger comes from Microsoft.Extensions.Logging. My problem is I can't make it to do:
The function just to log what I put in my C# code using ILogger. Either information, exception, warning, ...
ex: log.LogInformation("my log");
Nothing from the built-in logging features including errors, exception, dependency, nothing
I want the exact host.json logging value that does that.
ONLY WHAT I PUT IN C# CODE AND NOTHING ELSE.
Example of my code:
[FunctionName("GetNetworkHouseDetail")]
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "network/houseMonitoringDevices")] HttpRequest req, ILogger log, ClaimsPrincipal claims)
{
try
{
var start = DateTime.UtcNow;
// some actions
var end = DateTime.UtcNow;
var duration = (end - start).TotalSeconds;
log.LogInformation($"API - GetNetworkHouseDetail: took {duration} second to finish");
return new OkObjectResult(JsonConvert.SerializeObject(result));
}
catch (Exception ex)
{
log.LogError($"{ex.GetExceptionMessages()}", ex);
}
}