Breaking Change: Revert the Console Formatter Default in .NET 6 Container Images
- Dominant language
- No language data
- Stars
- 1.4k
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
In the .NET 6 `aspnet` container images we made the decision to default the console logger in `CreateDefaultBuilder()` to structured JSON logs in order to support container environments where folks use tools like fluentd or Azure Monitor to collect those logs. However, this resulted in non-human readable output that does not work well when viewing this output to analyze logs. [Please see this issue for more details](https://github.com/dotnet/dotnet-docker/issues/2725). We have made the decision to revert the default behavior back to multiline human-readable output.
### Discussion
You can share your thoughts on this change or see what others are saying at:
https://github.com/dotnet/dotnet-docker/issues/3642
### Servicing Update
In the May 2022 servicing update for .NET 6, we will change the `Logging__Console__FormatterName` environment variable to be unset for the ASP.NET Core container images. This will cause it to revert back to the original simple output.
Output of original .NET 6 behavior with `Logging__Console__FormatterName` set to `Json`:
```{"EventId":37,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.Server.HttpSys.MessagePump","Message":"Overriding address(es) \u0027\u0027. Binding to endpoints added to UrlPrefixes instead.","State":{"Message":"Overriding address(es) \u0027\u0027. Binding to endpoints added to UrlPrefixes instead.","{OriginalFormat}":"Overriding address(es) \u0027\u0027. Binding to endpoints added to UrlPrefixes instead."}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7000/","State":{"Message":"Now listening on: http://localhost:7000/","address":"http://localhost:7000/","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7001/","State":{"Message":"Now listening on: http://localhost:7001/","address":"http://localhost:7001/","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://localhost:7002/","State":{"Message":"Now listening on: http://localhost:7002/","address":"http://localhost:7002/","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Development","State":{"Message":"Hosting environment: Development","envName":"Development","{OriginalFormat}":"Hosting environment: {envName}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: C:\\Users\\shirh\\source\\temp\\web50","State":{"Message":"Content root path: C:\\Users\\shirh\\source\\temp\\web50","contentRoot":"C:\\Users\\shirh\\source\\temp\\web50","{OriginalFormat}":"Content root path: {contentRoot}"}}
```
Output of the upcoming .NET 6 behavior with `Logging__Console__FormatterName` left unset:
```
warn: Microsoft.AspNetCore.Server.HttpSys.MessagePump[37]
Overriding address(es) ''. Binding to endpoints added to UrlPrefixes instead.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:7000/
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:7001/
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:7002/
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\shirh\source\temp\web50
```
### Breaking Change
Question: What do I do if this change breaks my system that relies on JSON formatting?
If you are currently using or want to use JSON, you will need to opt into this behavior since it will no longer be on by default. To do this please set the `Logging__Console__FormatterName` environment variable to `Json`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.