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?
cc @rynowak @glennc
On Kubernetes, logs from ASP.NET Core apps are garbled with color codes:
.NET
System.Consolewill not output colors when it is not connected to a terminal. This is the case on Kubernetes, whereConsole.IsOutputRedirectedreturnstrue.ConsoleLoggerdoesn't considerIsOutputRedirectedand outputs colors regardless.Behaving like
Consolewould 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 totruewhenConsole.IsOutputRedirectedistrue?cc @rynowak @glennc