bdunagan

Brian Dunagan

October 6 2011
Rack Tip: ActiveRecord with Logging

Using ActiveRecord in Rack is one line of Ruby code, and setting up database logging outside of Rails is just as easy. As a minor extension of this excellent tidbit, you simply instantiate the Logger object with a file path. Here's the code:

require 'active_record'
require 'active_support'
ActiveRecord::Base.logger = Logger.new("log/db.log")
# ActiveRecord::Base.establish_connection(...)
Rails Tip: Locking Cron Jobs Rails Tip: Logger in Rake
LinkedIn GitHub Email