D
D
deadvip2012-10-09 19:48:11
Ruby on Rails
deadvip, 2012-10-09 19:48:11

Separate log file for the controller. Rails?

There is a project

controllers<br>
    admin<br>
        application_controller.rb<br>
    api<br>
         application_controller.rb<br>
    application_controller.rb<br>

A logger is included in production.rb: config.logger = Logger.new(config.log_path) which writes everything to production.log.
There is a task - when requesting controllers from the api folder, write to api.log, but not to production.log. The question is how easy is it to implement? I tried to add to api/application_controller.rb:
ActiveRecord::Base.logger = Logger.new("#{Rails.root}/log/api.log")<br>
ActionController::Base.logger = Logger.new("#{Rails.root}/log/api.log")<br>

Then everything is written to api.log, even what should be written to production.log. Adding code to admin/application_controller.rb and controllers/application_controller.rb:
ActiveRecord::Base.logger = Logger.new("#{Rails.root}/log/production.log")<br>
ActionController::Base.logger = Logger.new("#{Rails.root}/log/production.log")<br>

did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sl_bug, 2012-10-09
@sl_bug

Try to modify this crutch github.com/rails/rails/issues/2639#issuecomment-2252326

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question