Default log retention times
By default, FreePBX Distro is configured to keep a seven day history for most Asterisk log files.
This is not necessarily long enough to troubleshoot issues going back in time, especially for clients that look at their phone bills once a month or when trying to find a pattern to rare call error events.
Configure log retention times
Log file retention is set through the configuration file /etc/logrotate.d/asterisk. The following example increases log file retention to 60 days.
- Edit the file to set the log rotation period to 60 days and add compression for the second group of log files
The logrotate program will pick up on the changes the next time it runs and keep a longer log history in the future.
Disk space considerations
Note that the each day's "full" log file can be several megabytes large (depending on PBX call volume).
The addition of the line "compress" to the section of logrotate commands (as in the example above) causes the affected log files to be compressed with gzip.
The zgrep command can be used just like the grep command, but will transparently search both compressed and uncompressed log files
Configuring log rotation for additional FreePBX log files
There are some FreePBX log files not rotated in the default FreePBX Distro configuration. If desired, the following can be added to the end of /etc/logrotate.d/asterisk to ensure these files are trimmed back at regular intervals.
- Add the following content to the end of the /etc/logrotate.d/asterisk file to add log rotation for the specified log files