加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 为rails应用程序轮换日志的最佳方法是什么?

发布时间:2020-12-16 20:37:21 所属栏目:百科 来源:网络整理
导读:我有一个1片的slicehost,我有4个项目运行在该盒子.所有4个应用程序都是ruby的rails应用程序.我想知道什么是确保日志文件旋转的最佳方法. 我希望为每个应用程序提供4个不同的日志文件,而不是为所有4个应用程序提供一个大的日志文件. 我正在运行ubuntu. 我正在
我有一个1片的slicehost,我有4个项目运行在该盒子.所有4个应用程序都是ruby的rails应用程序.我想知道什么是确保日志文件旋转的最佳方法.

我希望为每个应用程序提供4个不同的日志文件,而不是为所有4个应用程序提供一个大的日志文件.

我正在运行ubuntu.

我正在乘客

解决方法

我也使用logrotate(你必须通过apt-get安装).在/etc/logrotate.d/目录中创建一个新的logrotate文件.这是我的一个例子:
# for the rails logs
/home/apps/*/shared/log/*log {
  daily
  rotate 14
  notifempty
  missingok
  compress
  sharedscripts
  postrotate
    /usr/bin/touch /home/apps/application1/current/tmp/restart.txt
    /usr/bin/touch /home/apps/application2/current/tmp/restart.txt
  endscript
}
# for the apache logs
/home/apps/logs/*log {
  daily
  rotate 14
  notifempty
  missingok
  compress
  sharedscripts
  postrotate
    /etc/init.d/apache2 restart
  endscript
}

这样可以让rails生成日志和apache访问/错误日志(我在乘客下运行我的应用程序).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读