Bitnami Logrotate

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.

Logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files.

How to configure logrotate for each server?

Logrotate files for different servers are stored in the installdir/config/logrotate/logrotate.d directory. For instance, to configure the Apache *logrotate file, edit the file at installdir/config/logrotate/logrotate.d/apache. Use the man logrotate command for information on all available options.

By default, logrotate uses the "copytruncate" approach so it is not necessary to restart the servers.

IMPORTANT: The "copytruncate" approach truncates the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one. There is a very small time slice between copying the file and truncating it, so some logging data might be lost. To record every request, use a different approach for rotating the logs.

How to enable logrotate?

Recent versions of Bitnami stacks ship logrotate configuration files for all servers.

If you are using a Linux native installer, the logrotate files are stored in the installdir/config directory. To enable logrotate, create a symbolic link, as shown below:

$ sudo ln -s installdir/config/logrotate/bitnami.conf /etc/logrotate.d/bitnami.conf

How to check if logrotate is working properly?

The command below displays the current logrotate configuration for your servers:

$ sudo logrotate -d /etc/logrotate.d/bitnami.conf

rotating pattern: installdir/apache2/logs/*_log  weekly (150 rotations)
empty log files are rotated, old logs are removed
considering log installdir/apache2/logs/access_log
  log does not need rotating
considering log installdir/apache2/logs/error_log
  log does not need rotating

To test logrotate, run the command below and then check the server's log/ directories which should contain the compressed files with the logs:

$ sudo logrotate -f /etc/logrotate.d/bitnami.conf
NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.