gpt4 book ai didi

ruby-on-rails - 为 rails 应用旋转日志的最佳方式是什么

转载 作者:行者123 更新时间:2023-12-03 00:25:51 24 4
gpt4 key购买 nike

我有一个来自 slicehost 的 1GB 切片,并且该盒子上运行着 4 个项目。所有 4 个应用程序都是 ruby​​ on 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 production.log日志和apache访问/错误日志(我在passenger下运行我的应用程序)。

关于ruby-on-rails - 为 rails 应用旋转日志的最佳方式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1590026/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com