-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-Extensions-Loggingbreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.Issue or PR that represents a breaking API or functional change over a prerelease.enhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions
Milestone
Description
On Kubernetes, logs from ASP.NET Core apps are garbled with color codes:
�[40m�[1m�[33mwarn�[39m�[22m�[49m: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory '/opt/app-root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
�[40m�[1m�[33mwarn�[39m�[22m�[49m: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {2c2776a6-be46-4719-9275-b7baed6ebc3f} may be persisted to storage in unencrypted form.
�[40m�[32minfo�[39m�[22m�[49m: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:8080
�[40m�[32minfo�[39m�[22m�[49m: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
�[40m�[32minfo�[39m�[22m�[49m: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
�[40m�[32minfo�[39m�[22m�[49m: Microsoft.Hosting.Lifetime[0]
Content root path: /opt/app-root/app
.NET System.Console
will not output colors when it is not connected to a terminal. This is the case on Kubernetes, where Console.IsOutputRedirected
returns true
.
ConsoleLogger
doesn't consider IsOutputRedirected
and outputs colors regardless.
Behaving like Console
would produce cleaner logs when running ASP.NET Core applications on Kubernetes (and other redirected environments).
I read through dotnet/extensions#673. There is a ConsoleLogger.DisableColors
. I'm not sure why it does not default to true
when Console.IsOutputRedirected
is true
?
lindexi and omajid
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-Extensions-Loggingbreaking-changeIssue or PR that represents a breaking API or functional change over a prerelease.Issue or PR that represents a breaking API or functional change over a prerelease.enhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions