微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

nginx.conf中的log_format被忽略

Nginx初学者在这里.

我的日志目前看起来像:

92.21.236.47 – – [08/Jan/2017:00:48:10 +0000] “GET / HTTP/1.1” 200 148 “-” “Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0″

当我在认的/etc/Nginx/Nginx.conf中添加以下行时

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

access_log /var/log/Nginx/access.log; 
error_log /var/log/Nginx/error.log;

(access_log和error_log行已存在于认配置中,我将这些仅用于上下文).

然后我重启Nginx

systemctl restart Nginx

我现在希望我的日志能够改变,特别是显示使用的xxx文字值.. xxx [$time_local] xxx ..但我的改变没有任何区别.

如果我将log_format main更改为log_format组合,则服务器将不会重新启动.

解决方法:

改变..

access_log /var/log/Nginx/access.log;

至 ..

access_log /var/log/Nginx/access.log main;

固定它.

其中main是log_format的名称,如…所定义.

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐