Node.js Forever is not creating Log files

forever, javascript, node.js

Solution

If you start your node process with `forever your_script.js` and don't specify a log file, `forever` will write your logs to the terminal (or `cmd` on Windows). The log file that is shown when you run `forever list` or `forever logs` does not reflect reality, since it's not created in that scenario. But if you specify log files, following the options:

-l  LOGFILE      Logs the forever output to LOGFILE
-o  OUTFILE      Logs stdout from child script to OUTFILE
-e  ERRFILE      Logs stderr from child script to ERRFILE

, like `forever -l console.log -e error.log your_script.log`, they will be created.

If you want `forever` to automatically create a log file for you, you have to start your script as a daemon, with `forever start your_script.js`. In this case, you can also specify your log files.

In the docs page you can see all the command line options.

Problem

2 nodejs scripts are being handled by `forever`. The system is using forever v0.11.1 and node v0.10.29 ``` # forever list info: Forever processes running data: uid command script forever pid logfile uptime data: [0] D34J userdown app/main.js 7441 10950 /root/.forever/D34J.log 0:2:31:45.572 data: [1] P0BX userdown app/main.js 11242 11261 /root/.forever/P0BX.log 0:2:20:22.157 # forever logs 0 error: undefined # forever logs 1 error: undefined ``` Question: Why are the log files created by `forever` missing? Restarting the 2 processes still doesn't create any log files... The directory `/root/.forever` does not show the log files too! ``` # ls -la /root/.forever total 20 drwxr-xr-x 4 root root 4096 Jul 4 11:37 . drwx------ 8 root root 4096 Jul 10 13:24 .. -rw-r--r-- 1 root root 259 Jul 10 19:34 config.json drwxr-xr-x 2 root root 4096 Jul 4 11:37 pids drwxr-xr-x 2 root root 4096 Jul 10 17:12 sock ```

Original source