How does one enable console logging in addition to AppInsights? I can see the insights just fine, but when I'm running locally, I would prefer to occasionally use a Console.WriteLine(...) here and there. Currently, I can't find the setting to enable both.
What I'm running:
- Isolated v4 Azure Function
- Http Trigger Function
- .NET 8
- C# Project
What I've tried:
host.json
{
"version": "2.0",
"logging": {
"console": {
"isEnabled": true,
"logLevel": {
"Function": "Debug"
}
},
...
}
note: I've tried with both "Function" and "default" under the "logLevel" setting
I have created Isolated http trigger function with runtime stack .net 8.0.
Function code:
Host.json:
Program.cs:
I have added console and application insights configuration in program.cs and log levels added in host.json.
The above function executed successfully. check below:
I am able to get the console logs and appinsight logs in applicationinsights.check below:
Output: