Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Turn off ANSI colors in console logs

How can I turn off ANSI colors from RabbitMQ console logs?

I have a RabbitMQ instance that logs to console in order to catch log messages elsewhere (on GCP logs for example).
The problem is that, all log messages are prefixed with ANSI color codes, which cause the logs to be interpreted as INFO always.

For example, on errors, RabbitMQ logs with [38;5;160m prefix, which corresponds for the red color. See screenshots.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here is my rabbitmq.conf

log.console = true
log.console.level = error
log.file = false

enter image description here

>Solution :

In most production environments, you would want to analyse your logs. This becomes easier when the logs are formatted in a structured way. In RabbitMQ it is possible to format logs in JSON, which will also solve your ANSI colouring problem:

log.file.formatter = json
log.console.formatter = json
log.syslog.formatter = json 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading