views:

22

answers:

1

I have to change my rail application's default log path because of my company's internal software deployment process: basically my rails app ends up on a read-only location, and I need the log files written in a directory "made for this".

With Rails 2.x we used to add some black magic in our FCGI script to force that in when deployed on prod. hosts:

class Rails::Configuration
   def default_log_path
     File.join(ENV['APOLLO_ENVIRONMENT_ROOT'], "var/output/logs/rails.log")
   end
 end

However, Configuration isn't a class anymore in Rails 2.3 (it's a module), and it appears to me there isn't any default_log_path involved there anymore as well...

A: 

You just need define your logger

config.logger = ActiveSupport::BufferedLogger.new(File.join(ENV['APOLLO_ENVIRONMENT_ROOT'], "var/output/logs/rails.log"))

This trick works with Rails 2 too. And you can define by environment where you really want your log file.

shingara
Actually Rails3 (at least) has a config.log_path which I used and worked perfectly. But I wouldn't have found without your (actually very sensible) solution :)
Romain
like you want. You can change your logger with the config.logger configuration too. Use Syslogger by example. Put your found on answer. It's more better.
shingara
Actually, is there a canonical source of information on these configuration properties? I haven't found one comprehensive one so far...
Romain
I don't really found too. But I think you can ask in SO Question :)
shingara