Way to disable Rails SQL logs?

后端 未结 3 753
清歌不尽
清歌不尽 2021-02-09 15:15

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

3条回答
  •  余生分开走
    2021-02-09 16:09

    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
    

提交回复
热议问题