Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to disable Rails SQL logs?

Is there a way to disable SQL logs in Rails, other than changing the log level? I've got some logger.debug statements that I'd like to print out in my ActiveRecord models, but I want to hide the SQL statements.

like image 791
dan Avatar asked Oct 28 '09 03:10

dan


2 Answers

You can moneky-patch it, put this in a file such as config/initializers/disable_ar_logging.rb:

class ActiveRecord::ConnectionAdapters::AbstractAdapter
  def log_info(*args); end
end
like image 185
Matt Haley Avatar answered Sep 21 '22 08:09

Matt Haley


Dan,

Is this in production or development mode? If it's development mode this is usually what I do:

logger.info("DEBUG my message here")
logger.info("DEBUG #{my_object.inspect}")

tail -f log/development | grep DEBUG
like image 42
Carlos Avatar answered Sep 24 '22 08:09

Carlos