Logging stdout to gunicorn access log?

后端 未结 4 1068
萌比男神i
萌比男神i 2021-02-06 06:38

When I wrap my Flask application in gunicorn writing to stdout no longer seems to go anywhere (simple print statements don\'t appear). Is there someway to either ca

4条回答
  •  温柔的废话
    2021-02-06 06:55

    You can redirect standard output to a errorlog file, which is enough for me.

    Note that:

    capture_output

    --capture-output
    False
    Redirect stdout/stderr to specified file in errorlog


    My config file gunicorn.config.py setting

    accesslog = 'gunicorn.log'
    errorlog = 'gunicorn.error.log'
    capture_output = True
    

    Then run with gunicorn app_py:myapp -c gunicorn.config.py

    The equivaluent command line would be

    gunicorn app_py:myapp --error-logfile gunicorn.error.log --access-logfile gunicorn.log --capture-output

提交回复
热议问题