Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created December 2, 2010 05:32
Show Gist options
  • Save ahoward/724825 to your computer and use it in GitHub Desktop.
Save ahoward/724825 to your computer and use it in GitHub Desktop.
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.gem 'logging', :lib => false
config.gem 'lockfile', :lib => false
# local libs/gems that can/must be loaded *inside* rails initializer
#
require 'logging' unless defined?(Logging)
require 'lockfile' unless defined?(Lockfile)
# force gem loading now
#
Rails::Initializer.run(:add_gem_load_paths, config)
Rails::Initializer.run(:load_gems, config)
# do the actual logging configuration - this one will keep 7 log files of
# roughly 42 mega-bytes on disk and fill not your lovely drive
#
require 'fileutils'
FileUtils.mkdir_p File.join(RAILS_ROOT, 'log')
logpath = config.log_path
number_rolled = 7
megabytes = 2 ** 20
max_size = 42 * megabytes
options = { :safe => true } # for multi-process safe rolling
logger = ::Logging.logger(
logpath,
number_rolled,
max_size,
options
)
config.logger = logger
config.logger.level = :info if RAILS_ENV=='production'
end
@michaeldv
Copy link

In Rails you can simply write 42.megabytes ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment