Balena cloud / device log coloring

Journald-logs article describes how to fetch device logs via the supervisor with a simple device logging solution in device-cloud-logging.

I have added a container implementing the logging solution. This logs output from containers, but the output got some coloring noise such as:

[?[47m?[30mapi?[39m?[49m] GET /v1/device 200

How can this coloring be disabled?

Hey there, could you please elaborate how you are trying to read the logs?
E.g. what happened to me is that if I use the command less logs.txt or vim I get this colouring noise as well, while with ```cat logs.txt`` it works perfectly fine.
Is that the case?

I use the following line:

curl -X POST -H "Content-Type: application/json" --no-buffer --data '{"follow":true,"all":true,"format":"short"}' "$BALENA_SUPERVISOR_ADDRESS/v2/journal-logs?apikey=$BALENA_SUPERVISOR_API_KEY" | /usr/sbin/tinylog -k 10 -s 10000000 "${LOG_PATH}"

Which pipes text + coloring ascii to file. Does not matter if I use cat, less, vi, nano. I get the noisy coloring ascii text.

If I use the following on device console:

curl -X POST -H "Content-Type: application/json" --no-buffer --data '{"follow":true,"all":true,"format":"short"}' "$BALENA_SUPERVISOR_ADDRESS/v2/journal-logs?apikey=$BALENA_SUPERVISOR_API_KEY"

I get all output, but the tty parses the coloring ascii and produce the actual colors, hence producing the correct text.

The use case is that I would like to log without coloring via the superviser endpoint.

I see, so it seems that this noise comes only when you try to use the pipe.
Did you try to spit this in 2 steps, e.g. save the outcome of the curl command and save it on a file and then apply the pipe on the file?


When using pipe the color tags and text are written to file as expected as no one is parsing the color information

When output to stdout/tty the color tags are parsed to the actuals colors, hence getting colored text

The color information originate from the endpoint. I would like to call the endpoint and not get coloring. I am only interested in the text

the journal-logs endpoint accepts a format parameter ( ) which will be passed to journalctl:
I think cat is the format you want.

The ‘cat’ format does not change anything regarding color. It only reduce the information level. The below image depict ‘cat’ format in tty:

It can be seen that api and debug are colored.

If piped to file the output looks like this:

[^[[47m^[[30mapi^[[39m^[[49m]     GET /v1/device 200 - 5.041 ms
[^[[47m^[[30mapi^[[39m^[[49m]     GET /v1/device 200 - 8.445 ms
[^[[47m^[[30mapi^[[39m^[[49m]     GET /v1/device 200 - 8.445 ms

Coloring should be changable from the following systemd argument:


The value must be a boolean. Controls whether colorized output should be generated. This can be specified to override the decision that systemd makes based on $TERM and what the console is connected to.

Since I am using the supervisor endpoint I need some argument to disable coloring coming from the systemd log supervisor endpoint

Thanks for the research. This looks like something we can reproduce in a test case and make the relevant changes to the supervisor API handler. In the mean-time, I believe that you can strip out the color information by removing any control codes by piping the logs to i.e. tr, such as tr -d '[:cntrl:]'