Question

I've got a PHP application on a free Heroku account. Today for no apparent reason I got Heroku's Application Error screen for about an hour. No downtimes on Heroku's status report page.

I'd like to check the logs to figure out why the application was down. But have no idea how to do this! Can somebody please help me?

Was it helpful?

Solution

Simply use heroku logs to display the last 100 lines of your logs.

Or to tail the logs in real-time: heroku logs -t

Heroku only saves the last 1500 lines of logs, which you can access using heroku logs -n 1500. If you want more logging, check out Heroku add-ons like Logentries or Papertrail.

OTHER TIPS

$ heroku logs -t --app app-name

This gives you all current logs (logentries add-on would be used)

heroku logs --tail

With the above command, you can see continuous Heroku logging.

Heroku is awesome but debugging applications on Heroku can be tedious. While technically all you need is $ Heroku logs --tail --app *and-your-app-name* that might not always paint the whole picture.

There are limitations like the 1500 loglines size or the 1MB buffer allowed for the response that you need to consider. For the average Joe, this is plenty and most of us don't even worry about them.

But every now and then you run into one of those limitations or maybe you don't run in a limitation per se but you do have to sift through countless lines of logs to find that one little message.

This is where most developers will look for outside help. There are plenty of tools that will manage your logs without breaking the bank or if money is no issue, well, there are services for that scenario too.

The most popular ones would be:

  • Sematext.com
  • Datadoghq.com
  • Logdna.com
  • logz.io

Here's how a service like that would look like.

For checking all the logs in Heroku console

config.logger = Logger.new(STDOUT)
config.logger.level = Logger::DEBUG

put these two lines inside the environment on which you are running your Heroku app(e.g. production.rb)

after that check logs here:

heroku logs -t

You can check detail logs there are also errors too if any.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top