This code is no longer needed. Heroku has provided syslog drains for all users for free.
For better Heroku logging with Papertrail, check this out:
http://help.papertrailapp.com/kb/hosting-services/heroku#standalone
This code is no longer needed. Heroku has provided syslog drains for all users for free.
For better Heroku logging with Papertrail, check this out:
http://help.papertrailapp.com/kb/hosting-services/heroku#standalone
gem 'remote_syslog_logger'
Take the example initializers (see below) for Rails 2 and 3 and put the correct one in config/initializers/
.
$ heroku config:add SYSLOG_URL=syslog://host.name.com:port/program
If you don't have a syslog target, get one for free from Papertrail.
On your next deploy you will be logging to that syslog host.
if ENV["SYSLOG_URL"] | |
require "remote_syslog_logger" | |
require "uri" | |
# redefine Rails.logger | |
def Rails.logger | |
@@logger ||= begin | |
url = URI.parse(ENV["SYSLOG_URL"]) | |
logger = RemoteSyslogLogger.new(url.host, url.port, :program => url.path[1..-1]) | |
logger.level = Logger::INFO | |
logger | |
end | |
end | |
# borrowed from Rails::Initializer#initialize_framework_logging | |
([ :active_record, :action_controller, :action_mailer ] & Rails.configuration.frameworks).each do |framework| | |
framework.to_s.camelize.constantize.const_get("Base").logger = Rails.logger | |
end | |
ActiveSupport::Dependencies.logger = Rails.logger | |
Rails.cache.logger = Rails.logger | |
end |
if ENV["SYSLOG_URL"] | |
require "remote_syslog_logger" | |
require "uri" | |
url = URI.parse(ENV["SYSLOG_URL"]) | |
logger = RemoteSyslogLogger.new(url.host, url.port, :program => url.path[1..-1]) | |
logger.level = Logger::INFO | |
Rails.logger = Rails.application.config.logger = ActionController::Base.logger = Rails.cache.logger = logger | |
end |
Nice! I'll probably be using this.