Breaking Change: Default console logger format set to JSON #3697
Replies: 11 comments
-
Is it by design or that configuring |
Beta Was this translation helpful? Give feedback.
-
@shirhatti - What takes precedence here? The |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
I have a hunch that (I ended up setting the environment variable inside the Dockerfile) |
Beta Was this translation helpful? Give feedback.
-
cc @shirhatti |
Beta Was this translation helpful? Give feedback.
-
@ralftar That's because {
"Logging": {
"Console": {
"FormatterName": "simple"
}
}
} We've unset ENV Logging__Console__FormatterName= And now everything works as expected. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Since we are diving into this 🐰🕳️ another observation for the record: Setting |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
This change has been reverted to the previous simple console logger behaviour with this second breaking change: #3706 |
Beta Was this translation helpful? Give feedback.
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
aspnet
image 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
aspnet
image type. Theruntime
andsdk
image 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__FormatterName
environment variable or via code change (see Console log formatting for more details).Example:
Related Issue
#2725
Beta Was this translation helpful? Give feedback.
All reactions