有没有办法在gunicorn中记录python打印语句

有没有办法在gunicorn中记录python打印语句

本文介绍了有没有办法在gunicorn中记录python打印语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用我的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打印语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 07:12