George
George

Reputation: 224

log management with PM2 [node]

If I have a remote log server, how to export log from pm2 to its url? And does PM2 have clever way to batch log instead of send log one by one (I'm afraid of the heavy traffic).

If original pm2 doesn't support it, how would you design with an external log server?

Upvotes: 1

Views: 795

Answers (1)

Stiekel
Stiekel

Reputation: 102

  • You can sync PM2 log files to remote log server with linux rsync command
  • Write a Node.js program, do with following:
    1. create a socket server on remote log server with Node.js
    2. watch the file change with fs.watchFile, read the new lines
    3. clear the log file empty
    4. transport the new lines to remote log server via socket

Upvotes: 1

Related Questions