Repository navigation
Breaking Change: Default console logger format set to JSON #3697
Replies: 11 comments
|
Is it by design or that configuring |
@shirhatti - What takes precedence here? The |
|
As I understand it, the environment variable takes precedence, so by setting the environment variable in the aspnet Docker images, it's no longer possible to configure console logging via appsettings.json. |
|
I have a hunch that (I ended up setting the environment variable inside the Dockerfile) |
|
@ralftar That's because {
"Logging": {
"Console": {
"FormatterName": "simple"
}
}
}We've unset ENV Logging__Console__FormatterName=And now everything works as expected. |
Thanks for pointing this out @wuhkuh, but a comment typo was also all that it was. The original question still stands: If Same applies to @wuhkuh's example above: Setting Regarding setting |
Ah, good catch, you're spot on: it uses the simple formatter because the environment variable now contains an empty string. To work around this, you can supply an entrypoint script, calling |
|
Since we are diving into this 🐰🕳️ another observation for the record: Setting |
|
Love this. I'm not using azure containers, rather bare metal droplets. After updating from .net5.0 to .net6.0, I figured out that the logger somehow changed it's configuration. So I've opened the docs and did not found any note or warning about this breaking change in there. Only 5 minutes of "googling" revealed me this issue. |
|
This change has been reverted to the previous simple console logger behaviour with this second breaking change: #3706 |
Uh oh!
There was an error while loading. Please reload this page.
Breaking Change: Default console logger format set to JSON
In the .NET 6
aspnetimage type, the default console logger format has been changed to a JSON formatter. The default in .NET 5 was set to the simple console formatter. This change was made in order to have a default configuration that works with automated tools that rely on a machine-readable format like JSON.Details
This change only impacts the
aspnetimage type. Theruntimeandsdkimage types are unaffected and remain configured with the simple console formatter.Any code which logs to the console will have its output affected by this change. As an example, the following output illustrates the differences in the default output when starting an ASP.NET Core container:
.NET 5 Output (simple format)
.NET 6 Output (JSON format)
Overriding the Default Configuration
The logger format type can be changed by setting or unsetting the
Logging__Console__FormatterNameenvironment variable or via code change (see Console log formatting for more details).Example:
Related Issue
#2725
All reactions