I currently have a controller were I would like to keep track of logging in a separate log file, like: tracker.log. I currently get about 100,000 hits a day with this, and I would like to separate the log from all the other controllers so I can easily debug those as well as the tracker.
I couldn't find anything for the Rails::Initializer, that would extend specifically for a controller.
I know it will be something along the lines of:
我目前有一个控制器,我想跟踪一个单独的日志文件,如:tracker.log。我目前每天获得大约100,000次点击,我想将日志与所有其他控制器分开,这样我就可以轻松地调试这些以及跟踪器。我找不到Rails :: Initializer的任何内容,它将专门为控制器扩展。我知道这将是:
config.log_path = 'log/tracker.log'
Although you can't re-run the Rails initializer mid load, right?
虽然你不能重新运行Rails初始化器中负载,对吗?
2 个解决方案
#1
You just need to create your own instance of the Logger class (which is used by Rails to generate log files) and pass it a File instance as an argument.
您只需要创建自己的Logger类实例(Rails用它来生成日志文件)并将其作为参数传递给它。
#2
#1
You just need to create your own instance of the Logger class (which is used by Rails to generate log files) and pass it a File instance as an argument.
您只需要创建自己的Logger类实例(Rails用它来生成日志文件)并将其作为参数传递给它。