簡體   English   中英

Apache2日志中的ServerName

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM