I found this very helpful, but I had to make further edits. Something tried to re-open the syslog, causing an unhandled RuntimeError. I fixed it with this axe-crazy override in environments/production.rb:
require 'rubygems'
require 'log4r'
require 'log4r/outputter/syslogoutputter'
# The outputter needs some love to avoid attempts to reopen syslog. Most of this is cargo-culted from source.
class Log4r::SyslogOutputter
def initialize(_name, hash={})
super(_name, hash)
ident = (hash[:ident] or hash['ident'] or _name)
logopt = (hash[:logopt] or hash['logopt'] or LOG_PID | LOG_CONS).to_i
facility = (hash[:facility] or hash['facility'] or LOG_USER).to_i
if Syslog.opened? then
@syslog = Syslog
else
@syslog = Syslog.open(ident, logopt, facility)
end
end
end
RAILS_DEFAULT_LOGGER = Log4r::Logger.new 'mylog'
config.logger = RAILS_DEFAULT_LOGGER
config.logger.outputters = Log4r::SyslogOutputter.new("f1", :ident=>"RoR")
config.logger.info "Starting up."
There's probably a much prettier way of doing it, but this would seem to do it for me.