Search code examples
node.jsterminalcolorssystemdansi-escape

Colored output from node stdout when redirected


I'm using 'colors' module with node js. When I run it simply with 'node app.js' I can see colored output in terminal.

However, when I redirect the output with 'node app.js > out.log &' or when I'm running it as a systemd daemon and looking on output with journalctl, colors are gone.

I want to be able to run node program as systemd daemon while being able to preserve colors in the log output. Please help me to understand the problem and find the solution if possible.


Solution

  • you see the output without colors because by default journalctl uses short as a output mode, if you use cat, you'll see your colors

    example:

    journalctl -o cat -u myservice.service