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",
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",
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.
$ pm2 logs app-name or pid | grep -i Keyword
You can grep the log output if that helps
$ pm2 logs | grep -i "KEYWORD"
pm2 logs
never exits (and also display by default only the last 20 lines)... –
Hutchison © 2022 - 2024 — McMap. All rights reserved.