Log rotation is already configured in apache and by default, it rotates the log files weekly as shown below in the default configuration file. But we need to change it if the log file size becomes very big in a week.
Default Configuration
[root@dbappweb ~]# cat /etc/logrotate.conf
# see "man logrotate" for details # rotate log files weekly weekly # keep 4 weeks worth of backlogs rotate 4 # create new (empty) log files after rotating old ones create . . . . .
Rotate Log Files Daily
We can change the value for rotation of the log file from weekly to daily to reduce the size of the log file.
By default, apache keeps the log file history of 4 weeks so we need to change the value of rotate from 4 to 30 for keeping the backlog of 30 days.
[root@dbappweb ~]# vi /etc/logrotate.conf
# see "man logrotate" for details # rotate log files daily daily # keep 30 days worth of backlogs rotate 30 # create new (empty) log files after rotating old ones create . . . . .
Note: I have made these changes on Apache 2.2.3 running on RHEL 5.8 server
Last Updated: May 12, 2018