Logging stdout to gunicorn access log?

后端 未结 4 1079
萌比男神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 07:00

    Use the logging: set the stream to stdout

    import logging
    
    app.logger.addHandler(logging.StreamHandler(sys.stdout))
    app.logger.setLevel(logging.DEBUG)
    
    app.logger.debug("Hello World")
    

提交回复
热议问题