Rails: Show SQL Queries in Production Log

Viewed 12155

How can we enabled SQL query logging in production environment?

Thanks,

Imran

2 Answers

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.

Related