1

I have a heroku app running (in production environment) on cedar stack. It uses postgres db.

In my environment/productions.rb file I have commented out this line

# config.log_level = :info

And in Heroku I have this config

$> heroku config
=== xxxx Config Vars
LOG_LEVEL:                    debug
RAILS_ENV:                    production

I want to view all db query that gets executed. In development environment locally I can see logs like this:

User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'xyz@gmail.com'   AND "users"."ustatus" IN (10, 11) LIMIT 1

But on heroku logs they never appear. Anyone know how to enable db log on heroku?

JVK
  • 3,782
  • 8
  • 43
  • 67

3 Answers3

1

Edit: I just found out why heroku does not display query logs when they should based on your production. rb configuration. The problem is queries will not be displayed by heroku if you have a so-called hobby tier plan. You are probably using the free version, which would explain why your queries are not displayed. If you would upgrade to a standard or medium plan the heroku logs will show the performed queries.

This heroku article explicitly says no postgres logs are displayed at hobby tier level: https://devcenter.heroku.com/articles/heroku-postgres-plans#hobby-tier

rails4guides.com
  • 1,441
  • 2
  • 11
  • 8
1

You can get the log from rails console on heroku by running below commands:

$ heroku run rails c
File.open('log/production.log', 'r').each_line { |line| puts line }

As I found here

heroku - how to see all the logs

Also here is heroku logging documentation:

https://devcenter.heroku.com/articles/logging

Community
  • 1
  • 1
Sumit Munot
  • 3,748
  • 1
  • 32
  • 51
  • this does not work. Even in that SO, you can see one comment is written as it is not working now. That SO question's answer is old and not relevant any more. This is now not working on cedar stack. – JVK Mar 08 '14 at 21:26
  • usually I will look my logs by adding --tail in heroku logs command that is $> 'heroku logs --tail' – Sumit Munot Mar 08 '14 at 22:29
  • Sumit, if you read my question carefully, then you will find, I am asking for Db logs. That does not show up in `heroku logs -t` – JVK Mar 09 '14 at 17:55
  • @jvk, here you go..http://stackoverflow.com/questions/8031007/how-to-increase-heroku-log-drain-verbosity-to-include-all-rails-app-details – Sumit Munot Mar 09 '14 at 18:12
0

Do everything by yourself:

  heroku run bash
Vitalyp
  • 1,069
  • 1
  • 11
  • 20