我们如何禁用添加到ASP.NET Core日志中的ANSI/VT100颜色代码 [英] How can we disable ANSI/VT100 color codes added to ASP.NET Core logs

查看:51
本文介绍了我们如何禁用添加到ASP.NET Core日志中的ANSI/VT100颜色代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Google Cloud中托管我们的ASP.NET Core服务,并且来自堆栈驱动程序的日志始终使用ANSI/VT100颜色代码,如下所示:

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

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

有没有办法告诉ASP.NET默认记录器不使用那些代码?

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

(P.S .:我知道我们应该转向结构化日志记录,接下来是)

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

推荐答案

基于 github问题,将 ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS env设置为 true 或将其添加到您的 appsettings.json :

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

"Logging": {
    "Console": {
      "DisableColors": true
    }
  }

这篇关于我们如何禁用添加到ASP.NET Core日志中的ANSI/VT100颜色代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆