Disable Rails SQL logging in console
To turn it off:
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
To turn it back on:
ActiveRecord::Base.logger = old_logger
Unable to turn off SQL logging in my Rails production environment
Per answer cited in comments, you need to add the following line to turn off SQL logging:ActiveRecord::Base.logger = nil
According to your posted config, you have ActiveRecord::Base.logger.level = Logger::INFO
instead. Replace this line with the one above and SQL logging will be disabled.
Additionally, as stated here, you could use ActiveRecord::Base.logger.level = 1
which will prevent exceptions caused by lesser levels of logs (ie: info, warn, etc.).
Turn off active record logging in production
To turn off completely, just add this to your environment file (i.e. production.rb
):
config.active_record.logger = nil
See AR guide (section 3.6):
config.active_record.logger accepts a logger conforming to the
interface of Log4r or the default Ruby Logger class, which is then
passed on to any new database connections made. You can retrieve this
logger by calling logger on either an Active Record model class or an
Active Record model instance. Set to nil to disable logging.
There's more options (like selectively turning on / off) documented in other posts. See Disable Rails SQL logging in console as a starting point.
Rails - how to disable all console logging?
Try changing the log level, which is info by default.
From the Guides: http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels
How can you hide database output in Rails console?
A better way of doing this is by typing this into the console:
ActiveRecord::Base.logger.level = 1
as it prevents problems trying use a pointer to a logger that is set to nil (source: Disable Rails SQL logging in console)
To turn it back on
ActiveRecord::Base.logger.level = 0
Disable log output to the Rails console
It seems that there's no clean way of doing this. The solution that I have found is to create file named config/initializers/disable_console_log.rb
and add the following content:
ActiveRecord::Railtie.instance_variable_set(:@load_console, [])
Disable Rails 3.2.1 Console SQL Logging
You don't have to have the console print the result of the last statement. This is a little bit of a contrived example but you can have your last statement be nil:
irb(main):156:0> Player.update_all(:IsActive => true); nil
SQL (1.8ms) UPDATE "players" SET "IsActive" = 't'
=> nil
How do I turn off Rails SQL logging in test?
Ok I found it. This worked:
config.after_initialize do
ActiveRecord::Base.logger = nil
end
Easy way to suppress SQL output in Rails console?
Enter this in the console, or put it in the console's config file:
ActiveRecord::Base.logger = nil
Related Topics
Oracle SQL Escape Character (For a '&')
SQL (Oracle): Order by and Limit
Transfer Data from One Database to Another Database
How to Delete Duplicate Rows with SQL
SQL Where Id in (Id1, Id2, ..., Idn)
Ssis Package Not Wanting to Fetch Metadata of Temporary Table
Postgres Dynamic Query Function
Bulk/Batch Update/Upsert in Postgresql
Using Pivot on Multiple Columns of an Oracle Row
Constraint for Only One Record Marked as Default
How to Find Duplicates Across Multiple Columns
How to Calculate a Running Total in SQL Without Using a Cursor
Group by Without Aggregate Function
Sql: Select Dynamic Column Name Based on Variable
How to Have Nhibernate Only Generate the SQL Without Executing It
Insert Rows into Multiple Tables in a Single Query, Selecting from an Involved Table