我有一个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
- }