Log rotation on Passenger + Apache

There are three different kinds of log files:

  1. The webserver (Apache/Nginx) log files.
  2. The Passenger log files.
  3. The application log files.

Passenger & webserver log rotation

Passenger logs to the global webserver error log. Whenever you rotate this log file you need to instruct Passenger to reopen it by running:

passenger-config reopen-logs

The webserver should also be made aware of the rotation, if it isn't already.

Application log rotation

Applications can have their own logfiles (e.g. Rails production.log), which are not related to - or controlled by - Passenger. If the logfile is rotated without the application being aware of the process, you'll need to restart it:

passenger-config restart-app <path to app>

Some applications just log to STDOUT, which is captured by Passenger and logged into the Passenger logfile (i.e. the global webserver error log). So if this is the case the application doesn't need a restart and you can just follow the log rotation procedure for Passenger.