Rails3 SQL log output in a separate file

I want all my ActiveRecord SQL records to be redirected to another file. It is useless to have it on the console or in the /development.log log.

How to do it? I would like to have it in the log / development_sql.log file.

thanks

+6
source share
2 answers
ActiveRecord::Base.logger = Logger.new('log/development_sql.log') 
+9
source

You can set it in config/application.rb :

 config.active_record.logger = Logger.new("log/development_sql.log") 
+6
source

Source: https://habr.com/ru/post/887911/


All Articles