Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

debugging - Is there a way to log python print statements in gunicorn?

With my Procfile like this:

web: gunicorn app:app 
    --bind "$HOST:$PORT" 
    --debug --error-logfile "-" 
    --enable-stdio-inheritance 
    --reload 
    --log-level "debug" 

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.

question from:https://stackoverflow.com/questions/27687867/is-there-a-way-to-log-python-print-statements-in-gunicorn

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In python 3, adding flush=True in each print statement works for my flask/gunicorn app.

E.g.

gunicorn --bind 0.0.0.0:8080 server --log-level debug

No particular flags are required.

See if this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...