I have a Heroku application written i Python. When it fails it does not log anything, but just stops code execution at the location of failure (it does not execute print statements just below) and then continues to run as nothing happens.
How can I display exception errors and traceback in the log? Is the behaviour different when exceptions are raised using the raise
statement?
I have set the following in the config file:
DEBUG = True
PRESERVE_CONTEXT_ON_EXCEPTION = True
Tried with and without PRESERVE_CONTEXT_ON_EXCEPTION
.
You can view logs with the Heroku CLI, the dashboard, your logging add-on, or in your log drain. You can't view logs for apps in Shield spaces with Private Space Logging enabled. Retrieve logs from your log drain instead.
It depends on your environment.
Try to add these lines:
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
app.logger.addHandler(stream_handler)
Also, if you run the server with Gunicorn, you should add --log-level debug
to your Procfile
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