JavaScript Answers

How to make Node pm2 log to console?

Spread the love

To make Node pm2 log to console, we call connect.

For instance, we write

const pm2 = require("pm2");

pm2.connect((err) => {
  if (err) {
        script: "server.js",
        output: "/dev/stdout",
        error: "/dev/stderr",
    (err, proc) => {
      if (err) {
        throw err;

to call connect with a callback that calls start with some options.

We set output to the location to '/dev/stdout' to log to the console.

And we log errors to '/dev/stderr' by setting error to "/dev/stderr".

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *