Log file rotation
As time passes, the size of the log files increases rapidly and starts occupying more and more disk space. To overcome this problem of the accumulation of logs over time, we generally keep the logs for the previous one or two weeks. To remove old log messages and retain the recent ones, Squid has a built-in feature of log file rotation, which can move older log messages to separate files. Moreover, Squid stores the incremental copy of the storage index in a file swap.state
, which is also pruned down during log rotation.
To rotate logs, we have to use the squid
command as follows:
$ squid -k rotate
This command will rotate logs depending on the value specified with the directive logfile_rotate
in the configuration file. The default value of logfile_rotate
is 10. This means that 10 older versions of all log files will be retained.
Have a go hero – rotate log files
Try to rotate log files on your proxy server and see how the log files are renamed.