Wednesday, January 28, 2015

How to: Creating multiple Apache log files on a per host basis

By default MAMP PRO logs your Apache errors in /Applications/MAMP/logs/apache_error.log. Errors originating from all hosts are entered into this single log file. It may be more convenient to have one log file for each individual host.

Open up your httpd.conf template file (Go to > File > Edit Template > Apache > httpd.conf) and scroll down to the “MAMP_VirtualHost_iteration_begin_MAMP” directive. Inside the httpd.conf template file add the following Errorlog directive (see line 10 in this code snippet).



This will create multiple log files in your /Applications/MAMP/logs directory. They will be named MyHostName1.log, MyHostName2.log, ….

Double check your work in your real httpd.conf file which is created every time you start your Apache server in ~/Library/Application Support/appsolute/MAMP PRO . You should see the following changes under each individual host. The following is the localhost:




UPDATE:
There´s a second method to generate multiple Apache log files:
You can create individual Apache error log files through the MAMP PRO interface. In the Hosts tab, under the Extended section you can add the following under the Additional parameters for "VirtualHost": section.

Advantages/Disadvantages

Method 1 - You only have to make one change to your httpd.conf template file and each subsequent host you create will have an Apache error log file created for it without any additional work. The disadvantage is you have less control over the name and location of your custom Apache log file.

Method 2 - You have more control over the name and location of your custom Apache log file. The disadvantage is that you have to enter the custom Apache log file name for each additional host you create. Error messages will appear in the default apache_error.log file If you forget adding a custom Apache error log file name for a particular host.

Share/Save/Bookmark