gpt4 book ai didi

python - Gunicorn 不选择 stderr

转载 作者:太空狗 更新时间:2023-10-30 02:30:54 24 4
gpt4 key购买 nike

我有一个具有以下路由的 Flask 应用程序:

@app.route('/')
def index():
console = logging.StreamHandler()
log = logging.getLogger("asdasd")
log.addHandler(console)
log.setLevel(logging.DEBUG)

log.error("Something")
print >> sys.stderr, "Another thing"
return 'ok'

我用

运行这个
python gunicorn --access-logfile /mnt/log/test.log --error-logfile /mnt/log/test.log --bind 0.0.0.0:8080 --workers 2 --worker-class gevent --log-level debug server:app

日志如下:

2014-06-26 00:13:55 [21621] [INFO] Using worker: gevent
2014-06-26 00:13:55 [21626] [INFO] Booting worker with pid: 21626
2014-06-26 00:13:55 [21627] [INFO] Booting worker with pid: 21627
2014-06-26 00:14:05 [21626] [DEBUG] GET /
10.224.67.41 - - [26/Jun/2014:00:14:14 +0000] "GET / HTTP/1.1" 200 525 "-" "python-requests/2.2.1 CPython/2.7.5 Darwin/13.2.0"
2014-06-26 00:14:14 [21626] [DEBUG] Closing connection.

我在索引方法中的日志发生了什么?

最佳答案

从 Gunicorn 19.0 开始,gunicorn 已停止将 stderr 重定向到其日志。

引用https://github.com/benoitc/gunicorn/commit/41523188bc05fcbba840ba2e18ff67cd9df638e9

关于python - Gunicorn 不选择 stderr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24420767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com