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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 为rails应用程序轮换日志的最佳方法是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个1片的slicehost,我有4个项目运行在该盒子.所有4个应用程序都是ruby的rails应用程序.我想知道什么是确保日志文件旋转的最佳方法.

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

我正在运行ubuntu.

我正在乘客

解决方法

我也使用logrotate(你必须通过apt-get安装).在/etc/logrotate.d/目录中创建一个新的logrotate文件.这是我的一个例子:
  1. # for the rails logs
  2. /home/apps/*/shared/log/*log {
  3. daily
  4. rotate 14
  5. notifempty
  6. missingok
  7. compress
  8. sharedscripts
  9. postrotate
  10. /usr/bin/touch /home/apps/application1/current/tmp/restart.txt
  11. /usr/bin/touch /home/apps/application2/current/tmp/restart.txt
  12. endscript
  13. }
  14. # for the apache logs
  15. /home/apps/logs/*log {
  16. daily
  17. rotate 14
  18. notifempty
  19. missingok
  20. compress
  21. sharedscripts
  22. postrotate
  23. /etc/init.d/apache2 restart
  24. endscript
  25. }

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

猜你在找的Ruby相关文章