Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python on Heroku. Logging options?

I am using Flask on Heroku right now and I want to be able to log errors to a file (via FileHandler).

I don't think that's officially supported by heroku.

On heroku's logging page there's some mentioning of syslogs and drains, which seem pretty complicated to set up.

I want something quick and easy. Any recommendations?

like image 798
disappearedng Avatar asked Oct 14 '12 19:10

disappearedng


People also ask

What are the two ways to view the logs from your Heroku app?

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.

What does Heroku logs -- tail mean?

Resolution. Apps that exceed a threshold of log output over a period of time can have their Heroku-provided log buffer disabled, meaning that only heroku logs --tail (live log tailing) will display logs. Note that this does not affect external log drains in any way.

How do I debug my Heroku app?

If running heroku local does not help, run a remote shell: heroku run -a <your app name> /bin/bash , and there run npm start to see the logs and debug the issue on the Heroku server.


2 Answers

Anything your app writes to stdout will end up in Heroku's consolidated log for your application, according to their docs, which you can then access with heroku log and the other tools. That's probably the quickest/easiest way to get logs from your app to a place you can look at them.

like image 150
dpassage Avatar answered Oct 22 '22 15:10

dpassage


Follow on heroku logging

To view your logs we have:

  1. logs command retrives 100 log lines by default.

heroku logs

  1. show maximum 1500 lines, --num(or -n) option.

heroku logs -n 200

  1. Show logs in real time

heroku logs --tail

  1. If you have many apps on heroku

heroku logs --app your_app_name

  1. You can use this addons papertrail. Log volume per day(10mb), search back of logs (2 days), archive duration (7days)
like image 20
Maxx Avatar answered Oct 22 '22 14:10

Maxx