NestJS logs have weird characters in log-management tools

Viewed 145

a simple question with a possibly simple answer I just cant seem to find:

We're using NestJS as our server-side javascript framework for a micro-service based infrastructure.

Working locally with the built in NestJS logger, or with our own class extending and implementing the logger functions, the console seems to print out the logs exactly as expected, for example:

[Nest] 41477  - 06/01/2022, 5:46:39 PM     LOG [Bootstrap] Mapped {/api/v1/accounts/:accountId/positions/:positionId/matches, GET} route

However, when running these service on cloud platforms, many (if not all) show-me-the-pod-logs tools add many "special" characters, for example:

[32m[Nest] 19  - [39m06/01/2022, 3:29:51 PM [32m    LOG[39m [38;5;3m[RouterExplorer] [39m[32mMapped {/api/v1/accounts/:accountId/positions/:positionId/matches, GET} route[39m[38;5;3m +1ms[39m

As you can see, it's almost the same, but not quite.. what are all of these [32m and [39m being added all over the place? This appears to be the same case in many of our tools: Datadog, ArgoCD pod logs, Rancher pod logs, etc.

What are these, and how can we get rid of them?

1 Answers

they are there for coloring the output (it's handled here). You can disable them by defining any value to the env. var. NO_COLOR (in your cloud environment, I guess)

Related