Back to blog

Log SQL queries in the Rails console

Tipsy tip

By Adrian Marin

October 23, 2025 60 words 1 min read

When debug queries in the console I often want to see the raw DB queries being made.

Here's a quick little piece of code which will make those queries visible in the console.

ActiveRecord::Base.logger = Logger.new(STDOUT)

This will tell the ActiveRecord logger to log out to STDOUT which is what we're using in the console.

Build your next rails app 10x faster with Avo

Avo dashboard showcasing data visualizations through area charts, scatterplot, bar chart, pie charts, custom cards, and others.

Find out how Avo can help you build admin experiences with Rails faster, easier and better.