Heroku: How can you check Heroku Error Logs?
Asked Answered
M

5

82

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?

Mraz answered 23/1, 2014 at 10:11 Comment(2)
Why do so many people give the exact same answer. heroku logs --tail does not show the full error traces. It didn't show them after I changed the production environment to "development" and changed the LOG_LEVEL variable.Sunrise
Possible duplicate of heroku - how to see all the logsDeathless
K
111

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.

Kalakalaazar answered 23/1, 2014 at 15:35 Comment(3)
Thanks to this answer I've found Papertrail. Just love it. here's how to set it up: help.papertrailapp.com/kb/hosting-services/heroku There's a free plan 100MBGalliett
whenever I type heroku logs it gives me Error: Missing required flag: » -a, --app APP app to run command against » See more help with --helpQuod
@Quod it means you need to add your app name on the command. For example, heroku logs -a your-app-nameMisbehave
C
38

$ heroku logs -t --app app-name

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

Cardiogram answered 5/6, 2015 at 5:48 Comment(0)
T
18
heroku logs --tail

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

Trevortrevorr answered 4/2, 2015 at 10:39 Comment(1)
This is what I was looking for! Thanks @Ajay.Granite
P
4

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.

Pyrope answered 25/5, 2020 at 0:10 Comment(0)
P
1

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.

Perception answered 29/4, 2016 at 9:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.