[英]Python “print” does not log to Forever.js Logs
A Python 2.7 script outputs some debug info via print
as it runs. Python 2.7脚本在运行时会通过
print
输出一些调试信息。
....
print datetime.now()
...
This script is started by forever.js : 该脚本由forever.js启动:
forever start -c python myPrintingScript.py
However when I want to check the output of the Python script, nothing shows up in the logs. 但是,当我要检查Python脚本的输出时,日志中没有任何显示。
Running forever logs 0
returns nothing. forever logs 0
运行forever logs 0
不会返回任何内容。 But the script definitely is running and has not crashed/restarted. 但是该脚本肯定正在运行,并且没有崩溃/重新启动。
Question: Is there a way to get the Python script to print debug info such that it also appears in the log files of forever
? 问题:有没有办法让Python脚本打印调试信息,使其也
forever
显示在日志文件中?
You can specify output logs for 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 -o out.log -e err.log myPrintingScript.py
Please do as this: 请这样做:
import sys
print "xxxx"
sys.stdout.flush()
Then you will see xxxx
in the log file that forever created. 然后,您将在永远创建的日志文件中看到
xxxx
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.