Azure / Azure/azure-functions-dotnet-worker

Unable to use a more compact format for console logs

Open
#2,386 0 comments 1 reaction 0 assignees View on GitHub
area: application-insights needs-investigation
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

Our goal is to reduce the number of log lines in the console (especially with exceptions):
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/4cc7c02a-a5ab-43c4-920a-661f33de529a)

We've tried using "AddSimpleConsole()" because the format suits us:
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/03369f3c-4393-41f9-afbb-14a0bd624917)

And the result is perfect:
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/cd8c4da5-a419-4251-b9ac-1036b3a12707)
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/506aa244-ddec-46e0-9cd4-af4a6056a7fb)

However, we have noticed an undesirable effect: the lines written to the console by "AddSimpleConsole()" are also sent to Application Insights (and are orphaned) with the "Host.Function.Console" category:
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/f670fcd9-0006-4e08-aa3b-bea7fc0a32c8)
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/a2b5e141-121c-412f-b80f-41c70cb048ba)
![image](https://github.com/Azure/azure-functions-dotnet-worker/assets/45167666/4c7b69a0-0cc7-44ff-adf1-881e5f6e9461)

Is it possible to change the format of logs in the console without duplicating them in Application Insights?

### Steps to reproduce

GitHub repo: [https://github.com/tovich37/azfunc-console-issue](https://github.com/tovich37/azfunc-console-issue)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the reproduction repository at https://github.com/tovich37/azfunc-console-issue and compare the console output with the Application Insights entries described in this issue. Trace how AddSimpleConsole() output is routed, and consider the work done when console logs use the compact format without producing duplicate or orphaned Host.Function.Console entries in Application Insights.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.