Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off active record logging in production

How can I turn off the verbose active record logging in production? (Like every SQL statement is logged) My logs are filling up really fast because I have background jobs running loads of queries. This is fine on my development server but I don't need this logged in production.

like image 511
Nick Barrett Avatar asked Mar 03 '14 02:03

Nick Barrett


1 Answers

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.

like image 152
steakchaser Avatar answered Oct 23 '22 16:10

steakchaser