Gary Sieling

Node: log files with Forever

“Forever” has arguments to set log file output. It’s important to get the order of the arguments correct (your file goes at the end), because anything after the javascript file name is passed as arguments to your script.

node_modules/forever/bin/forever start \
 -l /var/log/ssl-search-forever.log \
 -o /var/log/ssl-search-output.log \
 -e /var/log/ssl-search-error.log \
 index.js

You can then watch the output of these, like so:

tail -f /var/log/ssl-search-*

You also probably want log rotation – this is what I’m using (will update later if I run into problems with it)

/var/log/ssl-search*.log {
  daily
  dateext
  missingok
  rotate 7
  compress
  delaycompress
  notifempty
  copytruncate
}

If you want to control what goes into the access logs, you need to set up morgan correctly (this needs to happen at the beginning of the node app, not at the end):

app.use(require("morgan")("combined"));
Exit mobile version