Nginx開啟訪問日志記錄


1. vi /etc/nginx/nginx.conf

2.打開 log_format 前的注釋

3.Server節點中加入

access_log  logs/www_access.log  main;

server {
        listen       80;
        server_name  localhost;

      log_format main '$remote_addr - $remote_user [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent" "$http_x_forwarded_for"';


        location / {
            #root   html;
            #index  index.html index.htm;
        }
        access_log  logs/www_access.log  main;
}

4.重啟Nginx,會報錯,是因為沒有創建日文件所在目錄,建個目錄就可以了

mkdir  -p /usr/share/nginx/logs/

 

Enjoy :)...

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM