I use pm2 to keep my node.js app alive, I am starting my app with a configuration file that looks like this:
{
"name" : "myApp",
"script" : "app.js",
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"ignoreWatch" : ["node_modules","public"],
"watch" : true,
}
Additionally I am using the package colors to identify different types of messages but all the logs lose their color when I run the command
pm2 logs
My question is: what can I add to my configuration file to be able to see the colors in console?
When I did use a other logger modules, (like a colors, tracer )
(In my case,
var logger = require('tracer').colorConsole();
as logger )
{
"args": [ "--color" ]
}
this "args": "--color"
keeps my logger's log color.
Insert that code in your pm2 script,
then you can see your color log by that command: pm2 logs "id" --raw
(id is a pm2 id)
{
"name" : "myApp",
"script" : "app.js",
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"ignoreWatch" : ["node_modules","public"],
"watch" : true,
"args": [
"--color"
]
}
The process is needed to pm2 stop
, pm2 delete
and new pm2 start using script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With