I found the problem - I had copied the host.json from the example at docs https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"logLevel": {
"MyNamespace.HttpTrigger": "Information"
}
}
}
removing the "excludedTypes": "Request" allows the logged messages to appear in the application insights log; however, theu still do not appear in the log stream, even when setting the loglevel using the nameapce (as instructed above in the docs) or adding a default in the loglevel.
Azure Functions Logger using DI - examples in docs dont work
Avi Stokar
6
Reputation points
I am unable to get my own logger to log when using DI in Azure Functions. I have attached a very simple project which does not work. I have tried using Serilog (as in the attached example) or without it. Neither logs anything.
Additionally, I would like to use a non-generic ILogger, but that causes the DI container to crash with a unable to create an ILogger instance. (Unable to resolve ILogger from Microsoft.Extensions.Logging)
1 answer
Sort by: Most helpful
-
Avi Stokar 6 Reputation points
2021-07-18T16:06:36.887+00:00