Important:
This Item is only relevant for Linux.
In production environments, it is important to periodically compress/archive or truncate log file contents. Controlling your log file size prevents unnecessary disk consumption due to bloated log files. The following instructions describe how to override the native Zend Server log rotation mechanism and use logrotate.
Note:
logrotate
is not part of the Zend Server
product. To add this component you can use yum
and aptitude, according to your
distribution's repository.
For example, to locate the package in yum, run #
yum search logrotate. You can do the same with aptitude too. If
your distribution does not include this package in its repositories, you
can download the source from here: https://fedorahosted.org/logrotate/.
The following procedure describes how to configure automatic log rotation for all Zend Server logs, using the logrotate daemon. For full details on the third party logrotate utility, see the utility's man page (man logrotate).
This daemon is installed by default, or can be easily installed on all Zend Server supported Linux distributions.
Before using logrotate, make sure that the Zend component internal log rotation is disabled (see To_Disable_Log_Rotation).
|
|
|
To configure log rotation:
/usr/local/zend/var/log/*.log { size 5M missingok rotate 10 compress delaycompress copytruncate }
|
You have now created a configuration file for all the files located in /usr/local/zend/var/log/ that will be picked-up by logrotate. According to the above mentioned configuration, logrotate checks the file size of each log, every time it is executed (through a daily cron job on most systems). If the file size exceeds 5Mb, the log file is archived by moving the content to a new file and truncating the log file. The new file's name is the same name with an additional number added to the file name. According to the example, logrotate created up to ten backup files. After exceeding ten files, the oldest file is deleted and replaced with new content. The code example describes the following settings:
|
The following procedure describes how to disable Zend component internal log rotation.
|
|
|
To disable log rotation, set the log_rotation_size directive to 0. |
The default log rotation directive value is 10mb. |