Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top