{"action":"opened","issue":{"url":"https://api.github.com/repos/zibuyu1995/Monitoring/issues/3","repository_url":"https://api.github.com/repos/zibuyu1995/Monitoring","labels_url":"https://api.github.com/repos/zibuyu1995/Monitoring/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/zibuyu1995/Monitoring/issues/3/comments","events_url":"https://api.github.com/repos/zibuyu1995/Monitoring/issues/3/events","html_url":"https://github.com/zibuyu1995/Monitoring/issues/3","id":358682026,"node_id":"MDU6SXNzdWUzNTg2ODIwMjY=","number":3,"title":"Logging, Flask, and Gunicorn … the manageable way","user":{"login":"zibuyu1995","id":17525759,"node_id":"MDQ6VXNlcjE3NTI1NzU5","avatar_url":"https://avatars2.githubusercontent.com/u/17525759?v=4","gravatar_id":"","url":"https://api.github.com/users/zibuyu1995","html_url":"https://github.com/zibuyu1995","followers_url":"https://api.github.com/users/zibuyu1995/followers","following_url":"https://api.github.com/users/zibuyu1995/following{/other_user}","gists_url":"https://api.github.com/users/zibuyu1995/gists{/gist_id}","starred_url":"https://api.github.com/users/zibuyu1995/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zibuyu1995/subscriptions","organizations_url":"https://api.github.com/users/zibuyu1995/orgs","repos_url":"https://api.github.com/users/zibuyu1995/repos","events_url":"https://api.github.com/users/zibuyu1995/events{/privacy}","received_events_url":"https://api.github.com/users/zibuyu1995/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"zibuyu1995","id":17525759,"node_id":"MDQ6VXNlcjE3NTI1NzU5","avatar_url":"https://avatars2.githubusercontent.com/u/17525759?v=4","gravatar_id":"","url":"https://api.github.com/users/zibuyu1995","html_url":"https://github.com/zibuyu1995","followers_url":"https://api.github.com/users/zibuyu1995/followers","following_url":"https://api.github.com/users/zibuyu1995/following{/other_user}","gists_url":"https://api.github.com/users/zibuyu1995/gists{/gist_id}","starred_url":"https://api.github.com/users/zibuyu1995/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zibuyu1995/subscriptions","organizations_url":"https://api.github.com/users/zibuyu1995/orgs","repos_url":"https://api.github.com/users/zibuyu1995/repos","events_url":"https://api.github.com/users/zibuyu1995/events{/privacy}","received_events_url":"https://api.github.com/users/zibuyu1995/received_events","type":"User","site_admin":false},"assignees":[{"login":"zibuyu1995","id":17525759,"node_id":"MDQ6VXNlcjE3NTI1NzU5","avatar_url":"https://avatars2.githubusercontent.com/u/17525759?v=4","gravatar_id":"","url":"https://api.github.com/users/zibuyu1995","html_url":"https://github.com/zibuyu1995","followers_url":"https://api.github.com/users/zibuyu1995/followers","following_url":"https://api.github.com/users/zibuyu1995/following{/other_user}","gists_url":"https://api.github.com/users/zibuyu1995/gists{/gist_id}","starred_url":"https://api.github.com/users/zibuyu1995/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zibuyu1995/subscriptions","organizations_url":"https://api.github.com/users/zibuyu1995/orgs","repos_url":"https://api.github.com/users/zibuyu1995/repos","events_url":"https://api.github.com/users/zibuyu1995/events{/privacy}","received_events_url":"https://api.github.com/users/zibuyu1995/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-09-10T15:43:16Z","updated_at":"2018-09-10T15:43:16Z","closed_at":null,"author_association":"OWNER","body":"### 将Flask 日志整合到Gunicorn日志并输出\r\n\r\n### Example Code\r\n```python\r\n# coding: utf-8\r\n\r\nimport logging\r\n\r\nfrom flask import Flask, jsonify\r\n\r\n\r\napp = Flask(__name__)\r\n\r\n\r\n@app.route('/')\r\ndef index():\r\n    app.logger.debug('this is debug message')\r\n    app.logger.error('this is error message')\r\n    app.logger.critical('this is critical message')\r\n    return 'ok'\r\n\r\n\r\nif __name__ != '__main__':\r\n    # 如果不是直接运行，则将日志输出到 gunicorn 中\r\n    gunicorn_logger = logging.getLogger('gunicorn.error')\r\n    app.logger.handlers = gunicorn_logger.handlers\r\n    app.logger.setLevel(gunicorn_logger.level)\r\n\r\n\r\nif __name__ == '__main__':\r\n    app.run(host='0.0.0.0', port=8000, debug=True)\r\n```\r\n### Run:\r\n```bash\r\ngunicorn --workers=2 --bind=0.0.0.0:8000 --log-level=debug gunicorn_log:app\r\n```\r\n![image](https://user-images.githubusercontent.com/17525759/45308070-3cb1d300-b553-11e8-8da8-73301f8009a7.png)\r\n"}}
{"actor":{"display_login":"zibuyu1995"}}