12.10-12.12 Nginx的訪問日誌,日誌切割,靜態文件不記錄日誌和過期時間
阿新 • • 發佈:2018-04-25
nginx訪問日誌
12.10 Nginx訪問日誌
12.11 Nginx日誌切割
12.12 靜態文件不記錄日誌和過期時間
12.10 Nginx訪問日誌
1 打開配置文件,搜索/log_format,查看日誌文件格式。或者直接grep過濾出來
[root@AliKvn vhost]# grep -A2 log_format /usr/local/nginx/conf/nginx.conf
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]' ' $host "$request_uri" $status' ' "$http_referer" "$http_user_agent"';
2 其中combined_realip是日誌格式名稱,可以自定義。
#vim nginx.cnf
3 除了在主配置文件nginx.conf裏定義日誌格式外,還需要在虛擬主機配置文件中增加
[root@AliKvn vhost]# vim test.com.conf
access_log /tmp/test.com.log aming;
4 -t && -s reload 檢查並重新加載
[root@AliKvn vhost]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@AliKvn vhost]# /usr/local/nginx/sbin/nginx -s reload
5 curl測試
6 訪問日誌
12.10-12.12 Nginx的訪問日誌,日誌切割,靜態文件不記錄日誌和過期時間