Lets start all over and break apart this format string that is giving the error:
Would it be better written like this with escapes?
Code:
"%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
YES! Httpd loads up correctly now. If I add my local IP to /etc/hosts as example.com --- and if I write out a silly /etc/httpd/conf.d/vhosts.conf file for testing like this:
Code:
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
DocumentRoot /var/www/html
ErrorLog /var/www/html/error.log
CustomLog /var/www/html/requests.log1 test1
CustomLog /var/www/html/requests.log2 test2
CustomLog /var/www/html/requests.log3 test1
CustomLog /var/www/html/requests.log4 test2
</VirtualHost>
And add the formats to the conf/httpd.conf file, along with the test 'MYTEST' so we know its coming from these lines, in the "IfModule log_config_module" section like so:
Code:
<IfModule log_config_module>
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" MYTEST1" test1
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" MYTEST2" test2
Restart and look at our files that were created and their format:
Code:
[root@linux01 httpd]# cat /var/www/html/requests.log*
- - - [05/Jul/2017:15:45:00 +0000] "GET / HTTP/1.1" 200 12 "-" "curl/7.29.0" MYTEST1
- - - [05/Jul/2017:15:45:00 +0000] "GET / HTTP/1.1" 200 12 "-" "curl/7.29.0" MYTEST2
- - - [05/Jul/2017:15:45:00 +0000] "GET / HTTP/1.1" 200 12 "-" "curl/7.29.0" MYTEST1
- - - [05/Jul/2017:15:45:00 +0000] "GET / HTTP/1.1" 200 12 "-" "curl/7.29.0" MYTEST2
You can see that the aliases did their magic. The logformat string has to be formatted correctly and it has to be in the right place in the configuration file.