Heroku: How can you check Heroku Error Logs?

LoggingHerokuApplication Error

Logging Problem Overview


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?

Logging Solutions


Solution 1 - Logging

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.

Solution 2 - Logging

$ heroku logs -t --app app-name

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

Solution 3 - Logging

heroku logs --tail

With above command you can see continuous heroku logging.

Solution 4 - 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.

Solution 5 - Logging

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 also errors too if any.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAllen SView Question on Stackoverflow
Solution 1 - LoggingMikeView Answer on Stackoverflow
Solution 2 - LoggingCharles SkariahView Answer on Stackoverflow
Solution 3 - LoggingAjayView Answer on Stackoverflow
Solution 4 - LoggingJohn DemianView Answer on Stackoverflow
Solution 5 - LoggingsumitView Answer on Stackoverflow