Task:
Depending on where the request came to apache (on which hostname), write logs to a file that will contain the host or ServerName header or% {HTTP_HOST} in the log name. In this example, I mean that% {HTTP_HOST} is used
<VirtualHost 192.168.10.10:8888> UseCanonicalName Off ServerName test.example.ru ServerAlias test1.example.ru test2.example.ru VirtualDocumentRoot /home/%1/html CustomLog "/home/logs/%{HTTP_HOST}-access.log" combined In this case:
If the request came to test1.example.ru, the log should be written to: /home/logs/test1.example.ru-access.log .
If the request came to test2.example.ru then respectively in:/home/logs/test2.example.ru-access.log .
What methods can be implemented?
In particular, it is still interesting to specify the same logic for php logs
<IfModule mod_php5.c> php_value error_log "/home/logs/php/%{HTTP_HOST}-www-error_php.log" php_admin_value log_errors 1 </IfModule> Debian 7
Apache2 2.2.22-13
VirtualHostinto the number ofServerNameand in each register your file - does not suit you? - MANKKServerAlias *.example.rumay have a wildcard. In this example, I specifically indicated only three domains. - Kislik