Menu

#13 Node.js/PM2 Logging Support

Future Release
open
nobody
None
5
2019-08-12
2019-08-07
No

It would be great to see support for Node.js on LogWatch. It's very common to be running on servers now, so would be awesome to see support in LogWatch. I run it through PM2, which is very common. I guess the logging will be different through other process managers, so perhaps it's really PM2 logging support that I'm asking for.

Happy to provide details from my servers if this is something that is being taken forward.

Discussion

  • Nigel B. Peck

    Nigel B. Peck - 2019-08-07

    I've made an initial attempt at creating a service to handle the general PM2 log. This can be found on GitHub along with a typical example log file. It works with all of the PM2 logs on my server. It does not support any detail levels at this point.

    Services for application error and out logs will need adding.

    I would appreciate feedback in order to improve this, happy to work on it further, and hope it can be included in a future version of Logwatch.

    A pressing question/concern I have is that logs tend to be stored in a user's home directory under .pm2 so the current approach uses /home/*/.pm2/pm2.log. Not sure if that's a good idea for general use.

     

    Last edit: Nigel B. Peck 2019-08-11
  • Nigel B. Peck

    Nigel B. Peck - 2019-08-09

    This has now been updated to support application error logs. Updated code is on GitHub.

     

    Last edit: Nigel B. Peck 2019-08-11
  • Nigel B. Peck

    Nigel B. Peck - 2019-08-11

    This has now been updated to support reporting on PM2 status. It's a very rudimentary approach, suited really just to my own immediate needs, with ideas for development that would take a few hours. Really don't want to spend that time unless I hear back from you guys and this is something you want to take forward, so haven't done that work on it at this point. All the code, you guessed it, is on GitHub.

     

    Last edit: Nigel B. Peck 2019-08-11
  • Bjorn

    Bjorn - 2019-08-12

    Thanks for submitting the code. I don't use PM2, so cannot comment on its use. But wanted to comment on general Logwatch guidelines:

    • The default Detail value should be Low (=0), and should be set in the service script. At this level, only errors should be logged, with the briefest output. At Medium level (=5), more detail should be printed. At High level (=10), considerable output is allowed. Every service script is expected to make use of the Detail variable to reduce printed output. Some scripts use other values, when additional levels beyond those three are needed. Some scripts only make use of two levels (zero and ten).

    • It appears no allowance is made for rotated logs. Is there a standard logrotate script for PM2 that might shed light on how the logs are named?

    • pm2-status is a script to show real-time status. We discourage those in Logwatch, as it veers away from the 'logfile analyzer' function of Logwatch, although there are some (zz-*) that have been there for quite a while (and several are disabled by default).

    • From pm-status, it appears you also envision root as a user. If that is the case, it would appear that the LogFiles for pm2 and pm2-error expect to find log files under /home/root, which may not work in many systems.

     

Log in to post a comment.