问题描述
使用我的Procfile:
With my Procfile like this:
web: gunicorn app:app \
--bind "$HOST:$PORT" \
--debug --error-logfile "-" \
--enable-stdio-inheritance \
--reload \
--log-level "debug"
是否有可能以任何方式将python print
语句记录到stdout/bash中?如果这会影响任何因素,我也在这里使用bottle
框架.
is it in any way possible to get python print
statements to be logged to stdout / bash? I am using the bottle
framework here as well, if that affects anything.
推荐答案
事实证明print
语句实际上正在通过,但存在延迟.
It turns out the print
statements were actually getting through, but with delay.
用于--enable-stdio-的 gunicorn文档继承注意设置PYTHONUNBUFFERED
(我以为自己有设置),但语法似乎错误.
The gunicorn docs for --enable-stdio-inheritance note to set the PYTHONUNBUFFERED
, which I thought I had, but it seems with wrong syntax.
我在foreman
设置中使用.env
文件解决了此问题,设置了这样的变量:
I solved it using a .env
file with my foreman
setup to set the variable like this:
PYTHONUNBUFFERED=TRUE
这篇关于有没有办法在gunicorn中记录python打印语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!