#示例配置
#access_log:訪問日誌檔案路徑;
#buffer=32;緩衝在記憶體中,32k的記憶體空間,日誌先緩衝至記憶體中,根據時間節點,空間節點在儲存至硬碟中(效率更高);
變數定義:多數為nginx內建變數$remote_addr:客戶端位址;
$remote_user:客戶端使用者;
[$time_local]:收到使用者請求時伺服器本地時間;
$reques:請求的url;
$status:響應碼;
$bytes_sent:傳送客戶端的響應報文位元組數;
$http_referer:從什麼地方跳轉到當前頁面資源;
$http_user_agent:客戶端瀏覽器的型別;
$gzip_ratio:頁面資源壓縮比;
相關選項:max=n:設定快取中描述符的最大數量;
inactive=time:設定快取描述符關閉的時間(定義非活動時長,如果在此期間使用次數小於最小使用次數,定義非活動專案)預設10s;
min_uses=n:在由inactive引數定義的時間內檔案使用的最小次數;
簡單來講:在inactive=time時間內,快取項最少訪問min_uses=n次,為活動項,否則為非活動;
valid=time:設定檔案檢查(每隔多久檢查一次快取項是否有效);
off:禁用快取;
server:192.168.47.140
[root@gaoserver ~]# cat /etc/redhat-release
centos
linux release 7.2.1511 (core)
[root@gaoserver ~]# uname -r
3.10.0-327.el7.x86_64
[root@gaoserver ~]# nginx -v
nginx version: nginx/1.10.2
......
#在http配置段,定義日誌引數;注意,如果在server配置段中也同樣定義日誌引數,以server配置段中引數生效(最小定義);
} #建立日誌存放檔案上級目錄:
[root@gaoserver]# mkdir /var/log/nginx/nginx_log -pv
mkdir: 已建立目錄 "/var/log/nginx/nginx_log"
[root@gaoserver ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@gaoserver ~]# nginx -s reload
#訪問測試:
......
usage example:(官方示例)......open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;
access_log /var/log/nginx/access.log main;
open_log_file_cache max=100 inactive=20s valid=1m min_uses=2;
......
[root@gaoserver ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@gaoserver ~]# nginx -s reload
Nginx日誌配置
一,日誌格式 http referer http user agent 此日誌格式為,ip不僅記錄 的ip還記錄遠端客戶端真實ip。remote addr與 http x forwarded for 用以記錄客戶端ip位址,乙個記錄 ip,乙個記錄真實ip remote user 用以記錄客戶端使用...
nginx 日誌配置
不同使用者防衛nginx會把每個使用者訪問往咱的日誌資訊記錄到指定的日誌檔案裡,供 管理員分析使用者瀏覽行為等,此功能又ngx http log module 模組負責。控制訪問日誌的引數引數 說明log format 通過不同的名稱來定義日誌的輸出格式,可以定義多個 access log 用來指定...
nginx日誌配置
1.配置錯誤日誌 error log nginx 將遇到的不同嚴重級別問題的資訊寫入錯誤日誌。error log 指令設定對特定檔案,stderr 或 syslog 的日誌記錄,並指定要記錄的訊息的最低嚴重級別。預設情況下,錯誤日誌位於 logs error.log 絕對路徑取決於作業系統和安裝 並...