Reputation: 15423
How do I use pm2
to log only based off a keyword?
This is how pm2 is being called currently:
package.json file
"services": "pm2 start pm2.config.js --no-daemon",
Upvotes: 13
Views: 16733
Reputation: 435
I don't know if by default pm2 saves logs in a file, but, when using pm2 log rotate it does. So it works for me:
grep -r "KEYWORD" ~/.pm2/logs
I'm using EC2 Ubuntu and that is the default pm2 logs folder, you may change it according to your setup.
Update: It will not filter the log in real time, but it's useful if you need to find anything on older logs. If you need to filter logs in real time, you can grep the outpu with Hesam B answer, I just tested it, and it works, as shown below.
Upvotes: 11
Reputation: 65
You can grep the log output if that helps
$ pm2 logs | grep -i "KEYWORD"
Upvotes: 3