Patrick Angodung
Patrick Angodung

Reputation: 4831

Ruby on Rails SQL Logging

Is it possible in Ruby on Rails to log only the SQL commands generated and save it on a separate file?

I'm still in development mode and looking to save all the SQL commands on a seperate log.

I've checked the development.log files but they also save data like the

"Started GET "/assets/application.css" for 127.0.0.1 at 2014-02-17 16:41:47 +0800, etc.

I am looking to either create a separate log file only for SQL or remove these other lines leaving only the SQL commands.

Is this possible? Thank you.

Upvotes: 0

Views: 409

Answers (1)

Intrepidd
Intrepidd

Reputation: 20858

If you use active record, you can overwrite the active record logger :

ActiveRecord::Base.logger = Logger.new("#{Rails.root}/log/sql_log.log")

Upvotes: 1

Related Questions