36

How can we enabled SQL query logging in production environment?

Thanks,

Imran

1
  • 1
    I have tried different log_levels (config.log_level) with no luck. Commented Oct 27, 2010 at 19:29

2 Answers 2

55

In your environments/production.rb

config.log_level = :debug

Remember you need to restart the web server to apply the changes.

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

4 Comments

Thanks Simone. It works. I was trying with the numbers (0-4).
accept the answer because it's the good answer like you explain
Yes, I am trying but getting this message "You can accept an answer in 5 minutes" and waiting for this lag to get past :).
This doesn't work for me. Running production via rails s -e production
2

If you're setting the production log level to debug, I would recommend you to set the log level with an environment variable. Log level debug is much bigger than info and it can easily grow out of control or quotas if you're using a log service. So, with an environment variable you can change it faster only restarting rails, without the need for changing the code and deploy:

config.log_level = (ENV['LOG_LEVEL'] || :debug)

This way, you optionally set the environment variable LOG_LEVEL to change it.

1 Comment

Thank you for your info!; For production, default = :info would be better ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.