Heroku (Python/Flask) web app truncating log messages to only one line

心已入冬 提交于 2021-02-08 08:14:41

问题


I have a simple Python/Flask web that contains this:

@app.route('/index')
def index():
    app.logger.warning('test message 1\ntest message 2\ntest message 3')

Note the newline characters.

When I run it with heroku local web I see this in the logs:

web.1  | WARNING:app:test message 1

But when I push it to heroku instead of running it locally I see:

2015-12-09T22:23:21.102478+00:00 app[web.1]: WARNING in app[/app/app.py:17]: test message 1
2015-12-09T22:23:21.102482+00:00 app[web.1]: test message 2
2015-12-09T22:23:21.102483+00:00 app[web.1]: test message 3

Why does heroku local truncate the logs to the first line? I hate that and want it to stop.

My Procfile is:

web: gunicorn app:app --log-file -

I know it is not Flask or gunicorn doing that because when I run gunicorn by itself, I see

WARNING in app [/home/vagrant/Projects/milestone1/app.py:20]: test message 1
test message 2
test message 3

It has to be heroku local.

来源:https://stackoverflow.com/questions/34190400/heroku-python-flask-web-app-truncating-log-messages-to-only-one-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!