I want my a开发者_运维问答pp to create individual production logging file everyday for my rails application, so that the files size can be manageable? Is there a way to do so?
I would use something like logrotate that splits the can be set to run as a daily cron job. So that each day a new log file is created, or whatever interval you want. The nice thing about logrotate is that it can also gzip and email log files to keep them from piling up on your server.
Yes, however it's not part of rails. Look on your system, you should have a folder /etc/logrotate.d Inside of that folder, make a file for your app that looks something like this:
/var/www/apps/myapp/log/*.log {
daily
missingok
copytruncate
rotate 365
compress
notifempty
}
Essentially, this copies+compresses the old log and truncates the the file daily, and will delete archived files older than 1 year, unless the new log is empty.
精彩评论