node.js 永远存储 console.log 输出在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21021186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:37:16  来源:igfitidea点击:

Where does forever store console.log output?

node.jsforever

提问by AGamePlayer

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?

但我意识到日志被放置在其他地方。有什么提示吗?

回答by bryanmac

Forever takes command line options for output:

Forever 使用命令行选项进行输出:

-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 herefor more info

这里获取更多信息

回答by Liyan Chang

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

Forever,默认情况下,会将日志放入文件~/.forever/夹中的随机文件中。

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

您应该运行forever list以查看正在运行的进程及其相应的日志文件。

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 -las mentioned by bryanmac.

但是,最好-l按照 bryanmac 的说明进行指定。

回答by JosMarRivera

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

如果您运行命令“forever logs”,您可以看到日志文件在哪里。

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

来源:https: //github.com/foreverjs/forever

回答by Moh .S

try the command

试试命令

> forever logs

or

或者

> sudo forever logs

you will get the log file's location

您将获得日志文件的位置

回答by Zubair

This worked for me :

这对我有用:

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

回答by BanwariLal Bamalwa

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

需要正常 forever start script.js启动,并检查控制台/错误日志,使用 forever logs这将打印永久存储的所有日志的列表,然后您可以使用tail -f /path/to/logs/file.log,这会将实时日志打印到您的窗口。按 ctrl+z 停止打印日志。

回答by khan

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.

0 应替换为您要查看其输出的脚本编号。

回答by Loup G

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:

默认情况下,永远将它需要的所有文件都放在 /$HOME/.forever 中。如果您想更改该位置,只需在永远运行时设置 FOREVER_ROOT 环境变量:

FOREVER_ROOT=/etc/forever forever start index.js

回答by bhupen.chn

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.logoutput's are stored in these logs.

上面命令的示例输出,用于三个正在运行的进程。console.log输出存储在这些日志中。

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

回答by user450821

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

永远 -e /path/error.txt -o /path/output.txt 开始 index.js