当前位置:Gxlcms > 数据库问题 > nginx unknow log_format access in www.conf解决方法

nginx unknow log_format access in www.conf解决方法

时间:2021-07-01 10:21:17 帮助过:33人阅读

include       vhost/*.conf;

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

   
log_format access ‘$http_x_forwarded_for - $remote_user [$time_local] "$request" ‘
                ‘$status $body_bytes_sent "$http_referer" ‘
                ‘"$http_user_agent"‘ ;

在nginx.conf文件里面的日志可以使用main,access日志格式,但是换到vhost下面的conf文件就不能用了,不管什么格式:www.conf
加上日志格式:

access_log  /www/logs/sunrise.r.xiujj.cn.log access;

测试的时候就会提示:


nginx: [emerg] unknown log format "access" in /etc/nginx/conf/vhost/www.conf:3
nginx: configuration file /etc/nginx/conf/nginx.conf test failed



百度,谷歌全部千遍一律都是log_format没有打开的原因。

后来在阿里上提交工单,阿里工程师说是因为在上面include vhost/*.conf,然后再配置的日志格式。
加载配置的时候从上顺序加载,加载了conf还没有加载到日志格式,所以就是不管什么格式都是:
nginx: [emerg] unknown log format

把include放到最后面就可以了。。。

记录一下。都是不细心。。。以后得注意

本文出自 “Davin” 博客,请务必保留此出处http://ydw1118.blog.51cto.com/3035216/1669382

nginx unknow log_format access in www.conf解决方法

标签:nginx日志格式   nginx unknow log_format   

人气教程排行