Recently I worked on a project where the Rails logs were filling up way too quickly. Even though we had log rotation implemented, disk space was filling up fast. As a short term solution, we wanted to suppress all SQL logging Rails. Here's what I did.

#place this in environment.rb
class ActiveRecord::ConnectionAdapters::OracleAdapter
  def log_info(sql, name, runtime)
  end
end

What, you thought it would be difficult? This particular code works for Oracle; for MySQL just change the class to extend ActiveRecord::ConnectionAdapters::MysqlAdapter. For good measure, here's how I rotate logs in Rails:

#place this in environment.rb
Rails::Initializer.run do |config|
   config.logger = Logger.new("/path/to/logs/#{RAILS_ENV}.log", 5, 10485760)
end

This will rotate the logs up to 5 times, each file being about 10 megs in size.

Related posts:

  1. Using RCov to test Rails
  2. Deployment Using Capistrano / Webistrano via Rails / Phusion Passenger
  3. Ruby On Rails and SliceHost Part 1: Initial Setup
  4. Seconds to Minutes/Seconds in Rails
  5. Installing Ruby Enterprise Edition with Phusion Passenger