Reprinted from www.cnblogs.com/want990/p/1…

Nginx enables access logging

  1. vi /etc/nginx/nginx.conf

2. Open the comment before log_format

3. Add it to the Server node

access_log logs/www_access.log main;

Copy code server {listen 80; server_name localhost; Log_format main ‘$remote_addr -r emoteuser[remote_user [time_local] “KaTeX parse error: Double superscript at position 24: … ̲status bodybytess nt” body_bytes_sent “bodybytessent”http_referer” “http us er a g ent” ” Http_x_forwarded_for http_user_agent “” httpuseragent” “” “;

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

} Nginx is not created in the directory where the daily files are located

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