Redirect logger output for a specific controller in Rails 4

前端 未结 3 829
栀梦
栀梦 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:50

    The approach of using a different logging class for 1 controller has the downside that it won't work on a threading server which is in fashion these days not just with JRuby, but MRI too thanks to Heroku

    Only idea I have so far after giving it a week of thought is to pipe the logs to syslog and use syslog's facilities to split them into separate files.

    It would still require patching the Logger to include strings that would allow for the splitting (such as adding a formatted lined of from the #caller trace to the log files).

    Plan B would be to introduce my own logger and simply log what I need in that controller. You could easily dump params and response for example if that's enough

提交回复
热议问题