how to delete rails log file after certain size -


I have a daemon that runs continuously that fills the log file (development.log or production.log) is very fast What is the best way to remove the log file after a certain size or delete the part a few days ago?

The best way to set log rotation is, but how do you do it on this very platform Depending on, you should add a comment about using both for development and production.

On Linux, we have a file /etc/logrotate.d/appname for each app, which looks something like this:

 < Code> / path / to / rails_root_for_app / log /production.log {Daily unavailable 7 seconds delay compresscompress make notifempty 640 capistrano capistrano}  

This is to keep a compressed backup file for each day , Will move the log in a new file in one day, the last 7 days.

If you are running daemon, just want to clear the file without keeping any data from it, just do one shell:

  & gt; /path/to/rails_root_for_app/log/development.log  

This will make the file smaller in 0 bytes length.


Comments