Where does forever store console.log output?

node.jsForever

node.js Problem Overview


I installed forever and am using it, finding it quite funny.

But I realized that the logs are placed to somewhere else. Is there any tips?

node.js Solutions


Solution 1 - node.js

Forever takes command line options for output:

-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

For example:

forever start -o out.log -e err.log my-script.js

See here for more info

Solution 2 - node.js

Forever, by default, will put logs into a random file in ~/.forever/ folder.

You should run forever list to see the running processes and their corresponding log file.

Sample output

>>> forever list
info:    Forever processes running
data:        uid  command       script forever pid  logfile                         uptime
data:    [0] 6n71 /usr/bin/node app.js 2233    2239 /home/vagrant/.forever/6n71.log 0:0:0:1.590

However, it's probably best to specify with -l as mentioned by bryanmac.

Solution 3 - node.js

if you run the command "forever logs", you can see where are the logs files.

Source: https://github.com/foreverjs/forever

Solution 4 - node.js

try the command

> forever logs

or

> sudo forever logs

you will get the log file's location

Solution 5 - node.js

It is a old question but i ran across the same issues. If you wanna see live output you can run

forever logs

This would show the path of the logs file as well as the number of the script. You can then use

forever logs 0 -f

0 should be replaced by the number of the script you wanna see the output for.

Solution 6 - node.js

This worked for me :

forever -a -o out.log -e err.log app.js

Solution 7 - node.js

Need to do normal forever start script.js to start, and to check console/error logs use forever logs this will print list of all logs being stored by forever and then you can use tail -f /path/to/logs/file.log and this will print live logs to your window. hit ctrl+z to stop logs print.

Solution 8 - node.js

Help is your best saviour, there is a logs action that you can call to check logs for all running processes.

forever --help

Shows the commands

logs                Lists log files for all forever processes
logs <script|index> Tails the logs for <script|index>

Sample output of the above command, for three processes running. console.log output's are stored in these logs.

info:    Logs for running Forever processes
data:        script    logfile
data:    [0] server.js /root/.forever/79ao.log
data:    [1] server.js /root/.forever/ZcOk.log
data:    [2] server.js /root/.forever/L30K.log

Solution 9 - node.js

By default forever places all of the files it needs into /$HOME/.forever. If you would like to change that location just set the FOREVER_ROOT environment variable when you are running forever:

FOREVER_ROOT=/etc/forever forever start index.js

Solution 10 - node.js

You need to add the log destination specifiers before the filename to run. So

forever -e /path/error.txt -o /path/output.txt start index.js

Solution 11 - node.js

Based on bryanmac's answer. I'm just saving all logs into one file and then reading it with tail. Simple, but effective way to do this.

forever -o common.log -e common.log index.js && tail -f common.log

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAGamePlayerView Question on Stackoverflow
Solution 1 - node.jsbryanmacView Answer on Stackoverflow
Solution 2 - node.jsLiyan ChangView Answer on Stackoverflow
Solution 3 - node.jsJosMarRiveraView Answer on Stackoverflow
Solution 4 - node.jsMoh .SView Answer on Stackoverflow
Solution 5 - node.jskhanView Answer on Stackoverflow
Solution 6 - node.jsZubairView Answer on Stackoverflow
Solution 7 - node.jsBanwariLal BamalwaView Answer on Stackoverflow
Solution 8 - node.jsbhupen.chnView Answer on Stackoverflow
Solution 9 - node.jsLoup GView Answer on Stackoverflow
Solution 10 - node.jsuser450821View Answer on Stackoverflow
Solution 11 - node.jsNiko9911View Answer on Stackoverflow