rotatelogs - Piped logging program to rotate Apache logs

# apache2ctl -version
Server version: Apache/2.2.9 (Debian)
Server built:   Nov 14 2009 21:07:23
 
# rotatelogs
Incorrect number of arguments
Usage: rotatelogs [-l] [-f] <logfile> {<rotation time in seconds>|<rotation size in megabytes>} [offset minutes from UTC]
 
Add this:
 
TransferLog "|rotatelogs /some/where 86400"
 
or
 
TransferLog "|rotatelogs /some/where 5M"
 
to httpd.conf. The generated name will be /some/where.nnnn where nnnn is the
system time at which the log nominally starts (N.B. if using a rotation time,
the time will always be a multiple of the rotation time, so you can synchronize
cron scripts with it). At the end of each rotation time or when the file size
is reached a new log is started.
 
 
# vim /etc/apache2/envvars
 
# envvars - default environment variables for apache2ctl
 
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid
 
 
# vim /etc/logrotate.d/apache2
 
/var/log/apache2/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}

Ce dernier fichier devrait vous faire tourner toutes les semaines vos fichiers ".log" en laissant "fichier.de.votre.site.log" actif pour apache et les autres en archive "fichier.de.votre.site.log.1" jusqu'a "fichier.de.votre.site.log.52"