Nginx enables access logging

Reprinted from https://www.cnblogs.com/want990/p/11551440.html

Nginx enables access logging

  1. vi /etc/nginx/nginx.conf

2. Open the comment before log_format

3. Join in the Server node

access_log logs/www_access.log main;

复制代码
server {
listen 80;
server_name localhost;
      log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ remoteinser[time_local] “KaTeX parse error: Double superscript at position 24: … ' '̲status b o d y b y t e s s e n t " body_bytes_sent " bodyby t e ssent"http_referer” ’
‘“ h t t p u s e r a g e n t " " http_user_agent" " httpins and ragent""http_x_forwarded_for”’;

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

}
Copy code
4. Restart Nginx, an error will be reported, because the directory where the daily file is not created, just create a directory

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

Guess you like

Origin blog.csdn.net/weixin_44578029/article/details/110927738