Search code examples
node.jstypescriptloggingpm2

Disable pm2 logs


I am running node app via pm2 this way:

pm2 start npm -- start --node-args="--max-old-space-size=1024"

and package.json includes:

{
  "name": "my-app",
  "version": "1.0.0",
  "description": "...",
  "main": "index.js",
  "scripts": {
    "start": "npm run build && node dist/myManager",
    "build": "rimraf dist && tsc",
    "test": "jest"
  },
  . . .
}

It works as I need. Now I want to disable writing ~/.pm2/logs/npm-out.log. How can I do it?

I try something like according to pm2 documentation - https://pm2.keymetrics.io/docs/usage/log-management/

pm2 --output "/dev/null" start npm -- start --node-args="--max-old-space-size=1024"
pm2 --output="/dev/null" start npm -- start --node-args="--max-old-space-size=1024"
pm2 start npm -- start --node-args="--max-old-space-size=1024" --output "/dev/null"
pm2 start npm -- start --node-args="--max-old-space-size=1024" --output="/dev/null"

But it doesn't help.


Solution

  • You can run with flag --disable-logs to disable all logging from pm2.

    pm2 --disable-logs start npm -- start --node-args="--max-old-space-size=1024"

    It will still create the log files, but it won't write to them.