Squid Log Retention Settings

Access log of Squid proxy is automatically processed once a day by logrotate daemon using /etc/logrotate.d/squid configuration file. Default file contents look like the following.

#
#       Logrotate fragment for squid.
#
/var/log/squid/*.log {
        daily
        compress
        delaycompress
        rotate 2
        missingok
        nocreate
        sharedscripts
        prerotate
                test ! -x /usr/sbin/sarg-reports || /usr/sbin/sarg-reports daily
        endscript
        postrotate
                test ! -e /var/run/squid.pid || test ! -x /usr/sbin/squid || /usr/sbin/squid -k rotate
        endscript
}

For example, to store squid access log for 30 days, change the rotate 2 parameter to rotate 30. You can also add the maxage 30 to the configuration to make sure any rotated file is automatically deleted after 30 days. The conf file will then look like:

#
#       Logrotate fragment for squid.
#
/var/log/squid/*.log {
        daily
        compress
        delaycompress
        rotate 30
        maxage 30
        missingok
        nocreate
        sharedscripts
        prerotate
                test ! -x /usr/sbin/sarg-reports || /usr/sbin/sarg-reports daily
        endscript
        postrotate
                test ! -e /var/run/squid.pid || test ! -x /usr/sbin/squid || /usr/sbin/squid -k rotate
        endscript
}

Important

Virtual Appliance of Web Safety is configured to store the logs for 1 year. Depending on the amount of traffic processed by the proxy box you might need to manually change that to conserve the disk space.