【问题标题】:Gunicorn not picking stderrGunicorn 没有选择标准错误
【发布时间】:2014-06-26 00:37:58
【问题描述】:

我有一个带有以下路线的 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. 

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

【问题讨论】:

    标签: python flask gunicorn


    【解决方案1】:

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

    参考https://github.com/benoitc/gunicorn/commit/41523188bc05fcbba840ba2e18ff67cd9df638e9

    【讨论】:

      猜你喜欢
      • 2012-11-22
      • 2019-03-07
      • 2019-11-08
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 2013-11-28
      • 1970-01-01
      • 2014-08-22
      相关资源
      最近更新 更多