为什么旋转原木时导轨会崩溃?在轨道上旋转原木的正确方法是什么?
我不想经历使用 UNIX 的 logrotate 设置 4 个节点服务器(每个节点服务器有 3 个应用程序)的麻烦。
因此,我决定使用以下内部环境设置我的 Rails 应用程序。rb:
log_path = "#{Rails.root}/log/#{ENV['RAILS_ENV']}.log"
shift_age = 'weekly' # you can either 1) specify 2 params 50, 1024bytes OR 2) specify 1 param 'daily | weekly | monthly'
config.logger = Logger.new(log_path, shift_age)
但是,一旦文件翻转,这会导致 Rails 应用程序中断。
我想知道,使用 Rails 应用程序旋转日志的最佳方法是什么?是对数旋转吗?谢谢。
I did not want to go through the headache of setting up 4 node-servers with 3 applications each by using logrotate for UNIX.
So I decided to setup my rails applications with the following inside environment.rb:
log_path = "#{Rails.root}/log/#{ENV['RAILS_ENV']}.log"
shift_age = 'weekly' # you can either 1) specify 2 params 50, 1024bytes OR 2) specify 1 param 'daily | weekly | monthly'
config.logger = Logger.new(log_path, shift_age)
However, this caused the rails application to break once the files were rolled over.
I am wondering, what is the best way to rotate logs with rails applications? Is it logrotate? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发生这种情况的原因是,一个进程尝试轮换日志文件的同时,另一个进程也尝试轮换日志文件,出现竞争条件,并且服务器停止响应请求,并引发致命异常
This happens because one process is trying to rotate the log file at the same time that the another process is trying to rotate it, a race condition occurs, and the server stops responding to requests, as a Fatal Exception is raise