Writing logs to separate files for each domain in Apache

Administrator's picture

The default setting in Apache is for logs to store information (hits, page views etc.) in one log file. But what if you want to run reports for separate domain names or VirtualHosts on the server? You need a way to tell Apache to put the logfile information for each domain into a different file. Here's how it's done below. The main directive that needs adjusting in httpd.conf (the main confiuration file for Apache normally found in /etc/httpd/conf/httpd.conf - if you're not sure type "whereis httpd.conf") is in the section: ServerName www.yourdomain.comDocumentRoot /path/to/your/domainTransferLog /otherpath/to/your/logs/gen_msgErrorLog /otherpath/to/your/logs/error_msgBy specifying locations for TransferLog and ErrorLog in the VirtualHost directive for each domain in your httpd.conf file your logs will now be written to separate files. Simple eh?

23 people like this