[英]ServerName in Apache2 logs
我在Ubuntu 16.04机器上运行apache2.4。 我在/ etc / apache2 / sites-available中设置了两个文档根目录,每个根目录都具有不同的ServerName。 无论如何,是否也有将日志配置为捕获ServerName的原因,因为我想知道该请求的发出站点或记录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>
我已在同一Ubunutu框中将www.first.com设置为127.0.0.1,而我正试图从同一框中访问www.first.com。 access.log仍然不显示www.first.com。 有什么想法吗 ?
我从“ 自定义日志格式”一章可以理解,您需要%v
格式字符串:
%v The canonical ServerName of the server serving the request.
这意味着虚拟主机如:
ServerName example.com
ServerAlias example.net
ServerAlias example.org
...无论进入点是什么,总是以example.com
身份登录。
另外,标准的combined
昵称是:
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
您当然可以编辑它,但这有点令人困惑。 您可能想要分配一个不同的名称,如LogFormat示例:
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.