Use syslog facilities by default
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
It would be quite nice not to reinvent the wheel and just use the system's syslog facilities without having to install a pm2-syslog module and messing with UDP reception of rsyslog just to get the logging abilities (with OS-integrated log rotation and so on) like every other app does.
The existing tools that pm2 offers for logging are lacking.
pm2 logs <- gives me 15 lines, stdout and stderr are separate so I need to manually correlate timestamps - which stderr doesn't even have by default (why?)
pm2 logs --lines 1000 --out <- gives me a thousand lines and I have to scroll through the console just to find that I needed 2000 to get the timestamp I'm interested in.
pm2 logs --lines 1000 --out | more <- has me typing a marathon and loses the colors.
(I'm not counting pm2 logs --lines 1000 --out | head because then I have to rerun the command when I realize that I am at the right timestamps)
pm2 monit <- is horrible to navigate through once the log fills more than a screenful, the log lines flickering and jerking up and down when new lines are added while I scroll from the top with the cursor keys and wonder why the page up and page down keys don't work.
To read your log files in a way where I can at least all of the keys my keyboard has to offer, I currently have to type
vi ~/.pm2/application-name
and even after I did the finger training to get ~ / and mentally placing the . at the right spot, even then I only see one application, while realizing that log rotation isn't set up by default either, and the log file dates a year back and has onehundredandtwentyfive megabytes.
What can I do with every other program?
vi /var/log/syslog
Done.
Heck. Since once the system is set up, I don't usually touch config files, I can just do
!vi
Done.
Go to a timestamp?
/12:32:08<enter>
Not counting that grep and all that jazz is lightning fast on the combined syslog. And I get not just 15 lines, or 100, I get every single line in record time. If the log isn't needed, it gets gzipped (yay, storage saved), rotated, and eventually deleted.
You lose all that by reinventing the wheel and providing a half-baked solution. log4j reinvented the wheel and we all know how well that went.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names the pm2 logs and pm2 monit commands, plus the pm2-syslog and rsyslog setup, but no source files or tests. Start by tracing those logging entry points and document how output currently reaches log files. Done should mean a decided, tested design for using system syslog by default, including combined logs and OS-managed rotation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devops, observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100