Log Rotation
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/.
Configuring Log Rotation for Zend Server Logs
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 } /usr/local/zend/gui/lighttpd/logs/*.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:
|
To Disable Log Rotation
The following procedure describes how to disable Zend component internal log rotation.
|
|
|
To disable log rotation, follow the support KB below, which holds a shell script which automates the modification of log_rotation_size directive on all the affected Zend Server components, then restarts all services, instead of doing this manually on all ini files and DB schema. KB 203604773: Disabling-Built-In-Log-Rotation-in-Zend-Server |
Note: The default log rotation directive value is 10mb. |