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" = '[email protected]'   AND "users"."ustatus" IN (10, 11) LIMIT 1

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

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

4 Comments

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.
usually I will look my logs by adding --tail in heroku logs command that is $> 'heroku logs --tail'
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
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

1 Comment

Did you downvote? If so, could you please elaborate.
0

Do everything by yourself:

  heroku run bash

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.