I'm running apache2.4 on my Ubuntu 16.04 machine. I have set up two Document root each with different ServerName in /etc/apache2/sites-available. Is there anyway to configure the logs to capture the ServerName too because I want to know to site the request is made or log the DocumentRoot.
<VirtualHost *:80>
ServerName www.first.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/first
LogFormat "%{Host}i%U%q" combined
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have set www.first.com to 127.0.0.1 in the same Ubunutu box and I'm trying to access www.first.com from the same box. The access.log still don't show www.first.com. Any thoughts ?
My grasp from the Custom Log Formats chapter is that you need the %v
format string:
%v The canonical ServerName of the server serving the request.
That means that a virtual host like:
ServerName example.com
ServerAlias example.net
ServerAlias example.org
... always gets logged as example.com
no matter the entry point.
Also, the standard combined
nickname is this:
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
You're certainly allowed to edit it but it's kind of confusing. You may want to assign a different name, as in the LogFormat example:
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.