Disable logging in a node.js script running with forever

I am continually running a few server scripts (on different ports) with nodejs using forever.

There is a considerable amount of traffic on some of these servers. The console.log commands I have for tracking connection anomalies result in bloated log files that I don't need all of the time - only for debugging. I have been manually stopping the scripts late at night, truncating the files, and restarting them. This won't do for long term, so we decided to find a solution.

Someone else on my system deleted the log files I had set up for each of the servers without my knowledge. Calling forever list on the command line shows that the server scripts are still running but now I can't tail the log files to see how the nodes are doing.

Node downtime should be kept to a bare minimum, so I'm hesitant to stop the servers during daylight hours for longer than a few minutes. Initial testing from the client side seems to indicate that the scripts are doing fine, but I can't be 100% sure there are no errors due to failed attempts at logging to a nonexistent file.

I have a few questions actually:

  1. Is it ok to keep forever running like this?
  2. If not, is there a proper way to disable logging? The github repository seems to indicate that forever will still log to a default file, which I don't want. Otherwise I may just write a cronjob that periodically stops scripts, truncates logs, then restarts the scripts.
  3. What happens if I just create the logfile again with something like touch logfile_name.log while the script is still running - will this make forever freak out or is this a plausible solution?

Thanks for your time.

There's a nifty tool that can help you that called logrotate. Have a look here

Especially the copytruncate option, it is very useful in your case.

according to https://github.com/foreverjs/forever, try to pass -s to silent all log.

forever -s start YOURSCRIPT

Surely, before doing this, try to update forever to the latest:

sudo curl -L https://npmjs.com/install.sh | sudo sh

sudo npm update -g.