Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we disable ANSI/VT100 color codes added to ASP.NET Core logs

Tags:

asp.net-core

We are hosting our ASP.NET Core services in Google Cloud, and the logs from Stack Driver always use ANSI/VT100 color codes, like this:

[40m[32minfo[39m[22m[49m

Is there a way to tell the ASP.NET default logger to not use those codes?

(P.S.: I know we should move to structured logging, that's next)

like image 963
Martin Plante Avatar asked May 01 '18 14:05

Martin Plante


Video Answer


1 Answers

based on the github issue, set ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS env to true or add this to your appsettings.json:

"Logging": {
    "Console": {
      "DisableColors": true
    }
  }
like image 170
ahmadali shafiee Avatar answered Oct 10 '22 15:10

ahmadali shafiee