Rails 日志记录错误:“故障安全响应期间出错:转换失败。” ...有一个优雅的解决方案吗?
我已经在environment.rb中将我的Rails 2.3.8记录器配置为每天轮换:
config.logger = Logger.new("#{RAILS_ROOT}/logs/#{RAILS_ENV}.log", 'daily')
并且每天早上我都会得到通常的信息:
Error during failsafe response: Shifting failed.
是否有一个体面/优雅/更好的解决方案?
我过去所做的只是设置一个 cron 作业来注意何时发生这种情况,并将 Passenger restart.txt 文件放入应用程序的 tmp/ 目录中。
谢谢。
I've configured my Rails 2.3.8 logger in the environment.rb to rotate daily:
config.logger = Logger.new("#{RAILS_ROOT}/logs/#{RAILS_ENV}.log", 'daily')
and every day in the morning I get the usual:
Error during failsafe response: Shifting failed.
Is there a decent/elegant/better solution to this?
What I've done in the past is just set up a cron job to notice when this happens and to drop a Passenger restart.txt file in the app's tmp/ directory.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 UNIX/Linux 上使用名为 logrotate 的程序来执行日志文件轮换是很常见的。 Slicehost 有几篇不错的文章介绍如何使用它。
对于 Phusion Passenger 部署,您可以使用如下例所示的配置。显然适当地调整目录和轮换频率。
It's pretty common on UNIX/Linux to use a program named logrotate to perform log file rotation. Slicehost have a couple of nice articles on how to use it.
For a Phusion Passenger deployment you can use a configuration like the example below. Obviously adjust the directories and rotation frequency as appropriate.
如果您同时收到许多请求,那么 Rails 就需要轮换日志了。如果一个流试图写入一个文件(logger.rb 代码中有一行写着:@dev.stat.size)并且当该文件不存在(因为它正在旋转)时,它会抛出一个致命异常,基本上,服务器停止响应请求(它不一定会关闭,但会轰炸请求。
If you have many requests coming in simultaneously, and it is time for the Rails to rotate logs. If a stream is trying to write to a file ( the logger.rb code has a line that says : @dev.stat.size) and when the file does not exist (because it is being rotated) then it throws a fatal exception, and basically the server stops responding to requests (it doesn’t necessarily shut down, but bombs out on requests.