Nginx开启访问日志记录

转载自 https://www.cnblogs.com/want990/p/11551440.html

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 - r e m o t e u s e r [ remote_user [ remoteuser[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 " bodybytessent"http_referer” ’
‘“ h t t p u s e r a g e n t " " http_user_agent" " httpuseragent""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/

猜你喜欢

转载自blog.csdn.net/weixin_44578029/article/details/110927738