Redirect logger output for a specific controller in Rails 4

前端 未结 3 828
栀梦
栀梦 2021-02-07 08:57

I\'ve built a solution based on the answer in my previous question Redirect logger output for a specific controller in Rails 3 for Rails 3. It works great however now I am tryin

3条回答
  •  一向
    一向 (楼主)
    2021-02-07 09:36

    I'm not sure if you need to approach the solution in the same way as you had done in Rails 3. It seems there may be other ways to accomplish your end goal. Have you considered any of these approaches or gems?

    https://github.com/TwP/logging

    How to log something in Rails in an independent log file?

    Sometimes trying something completely different than what you've already done can be helpful IMHO.

    This is a bit of guess, but this may be why your getter setters are not working as expected: https://github.com/rails/rails/commit/6329d9fa8b2f86a178151be264cccdb805bfaaac

    Regarding Jagjot's solution and needing to set base log for each of the MVC Action Classes, Rails 4 sets these separately by default which would in tern seem to provide more flexibility out of the box. http://guides.rubyonrails.org/configuring.html#initializers

提交回复
热议问题