-
Notifications
You must be signed in to change notification settings - Fork 1.9k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking Change: Default console logger format set to JSON #3274
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) |
cc @shirhatti |
@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 issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
The text was updated successfully, but these errors were encountered: