lundi 2 mars 2015

Redirect logger output for a specific controller in Rails 3

We want to have a collection of controllers where we route logger output from all actions and downstream methods to a separate log file. This is a Rails 3 project. In Rails 2 we did this by redefining the "logger" method but in Rails 3, the way to log is using "Rails.logger". I tried putting



Rails::logger = Logger.new(File.join(Rails.root, 'log', "reports_controller.log"), 10, 1000000)


at the top of the controller, but only the specific cases where Rails.logger is used specifically in the action is getting sent to the specified log file, all of the default log output for the controller is still routing to the main log file.


How can we route all log output for a specific controller to a specific log file to include all default controller output?


Aucun commentaire:

Enregistrer un commentaire