开发者

Is it possible to create one unique individual file for the production logging for Rails application?

开发者 https://www.devze.com 2023-02-07 12:29 出处:网络
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 lik

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消