From f92ed693c0fe0e46d5f1491d7f0ac4662faff108 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 13 Mar 2007 14:54:43 -0500 Subject: [PATCH] Log rotation. By default, we now use the standard Ruby Logger class to rotate the Instiki logfile. This works fine with the default Webrick. But, if you're running under Mongrel (say), you probably want to customize this in config/environments/production.rb . --- app/models/wiki.rb | 4 ++-- config/environments/production.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/models/wiki.rb b/app/models/wiki.rb index 46073065..bd202ce2 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -2,7 +2,7 @@ class Wiki cattr_accessor :storage_path, :logger self.storage_path = "#{RAILS_ROOT}/storage/" - self.logger = RAILS_DEFAULT_LOGGER + self.logger = INSTIKI_LOGGER def authenticate(password) password == (system.password || 'instiki') @@ -89,4 +89,4 @@ class Wiki def write_page(web_address, page_name, content, written_on, author, renderer) Web.find_by_address(web_address).add_page(page_name, content, written_on, author, renderer) end -end \ No newline at end of file +end diff --git a/config/environments/production.rb b/config/environments/production.rb index f2b9ed68..6291d2f8 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -5,6 +5,21 @@ config.cache_classes = true # Use a different logger for distributed setups # config.logger = SyslogLogger.new +#### +# This one rotates the log file, keeping 25 files, of 1MB each. + +INSTIKI_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", 25, 1024000) + +# Unfortunately, the above does not work well under Mongrel, as the default Ruby logger class +# does no locking and you will have several processes running, each wanting to write to (and +# rotate) the log file. One solution is to have each mongrel instance writes to a different log file: +# http://blog.caboo.se/articles/2006/11/14/configure-mongrel-rails-logger-per-port for a solution. +# Another is to use the default logging behaviour: + +#INSTIKI_LOGGER = RAILS_DEFAULT_LOGGER + +# and use an external program (e.g. logrotate) to rotate the logs. +#### # Full error reports are disabled and caching is turned on config.action_controller.consider_all_requests_local = false