Log entries from function code is not appearing in console when running locally
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
###### Function App name:
N/A. Local testing.
###### Tools used:
VS 2022 Preview 6.0
###### New V4 app or existing V3 app migrated to V4:
New V4 In-proc app.
###### Runtime info:
> Azure Functions Core Tools
Core Tools Version: 4.0.3893 Commit hash: ef87e297a75893d676c3dea0eb01fbd1a3db5446 (64-bit)
Function Runtime Version: 4.0.0.16714
#### Issue:
The console logging provider does not appear to work. Logs emitted from my function app code is not shown on the console window, impacting local development flow.
#### Repro steps:
Create a V3 in-proc app and V4 in-proc app with an Http trigger function. Execute the http trigger function and compare logs emitted in the console.
V3 LOGS from console
```
Functions:
Function1: [GET,POST] http://localhost:7071/api/Function1
For detailed output, run func with --verbose flag.
[2021-10-21T18:37:25.900Z] Host lock lease acquired by instance ID '0000000000000000000000006DBDAA09'.
[2021-10-21T18:37:35.380Z] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=ea3e074c-1ed2-4e15-9291-71b45197e02f)
[2021-10-21T18:37:35.402Z] C# HTTP trigger function processed a request.
[2021-10-21T18:37:35.468Z] Executed 'Function1' (Succeeded, Id=ea3e074c-1ed2-4e15-9291-71b45197e02f, Duration=112ms)
```
V4 LOGS from console
```
Functions:
Function1: [GET,POST] http://localhost:7071/api/Function1
For detailed output, run func with --verbose flag.
[2021-10-21T18:38:32.467Z] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=2767e974-f68b-43fc-888d-9ae105ba8fb8)
[2021-10-21T18:38:32.580Z] Executed 'Function1' (Succeeded, Id=2767e974-f68b-43fc-888d-9ae105ba8fb8, Duration=138ms)
[2021-10-21T18:38:34.786Z] Host lock lease acquired by instance ID '0000000000000000000000006DBDAA09'.
```
Both functions are using the `LogInformation` extension method.

If I update the V4 function code to inject `ILogger` as a parameter (similar to what the V3 template produces) and use that instance, logging to console works fine.
```
[FunctionName("Function1")]
public async Task Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger _logger)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.