Rotating Log(Cfilelogroute) At 'midnight'


I have been referring this link for handling logs in my project. As it says there the log will rotate when it exceeds certain size. All existing log files are moved backwards one place, i.e., ‘.2’ to ‘.3’, ‘.1’ to ‘.2’.

This too happens upto 5 files (.5), loosing all the old logs.

I want it to rotate the log file at midnight like CI or Python and when it does the rotation, it should compress the old file (like CI). How do I do this? Please help.

If you are running a server running any soort of linux distribution I suggest you use the logrotate package. You can release log rotate on any log, it’ll rotate the number you want and compress as well.

Okay! Thanks! I didn’t know that.

Currently I have increased the logsize to 10Mb and set number of log files to 5; All from Yii’s config file.

I searched for logrotate package in linux and found -

It seems good. I’ll try this too.