I am working with Flask and Foreman for the Heroku hosting. I start my local server typing foreman start
. My issue is that I want to see the log error messages that my code produces but I haven't found the right way to do it.
I tried with some code that I found in the Flask documentation like this, but it doesn't work either:
import logging
from FileHandler import FileHandler
file_handler = FileHandler("log.txt")
file_handler.setLevel(logging.WARNING)
app.logger.addHandler(file_handler)
Any idea how to be able to read de error messages when running Flask with foreman start
?
I had a similar problem - in the end the issue wasn't with Foreman, but with using a newer version of Gunicorn where console logging was disabled by default (http://gunicorn-docs.readthedocs.org/en/latest/faq.html#why-i-don-t-see-any-logs-in-the-console).
Changing my procfile from:
web: gunicorn app:app
to
web: gunicorn --log-file=- app:app
solved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With