nginx: [warn] "log_format" directive used only on "http" level 解决方法
将nginx升级到1.2.4稳定版之后,会发现之前的vhost/*.conf中的日志配置都报了如下的warn:
nginx:[warn]the“log_format”directivemaybeusedonlyon“http”level
上网搜索解决方案如下:
将/vhost/xxx.conf里server段里的下面代码移出该server段即可。
但是这样的又会产生一个问题,就是各子域名的日志文件都会记录所有请求的日志,等了好久都没找到解决方案,后来请教了飞飞之后终于找到解决的方法了。
原来log_format需要在nginx.conf的http层定义,然后在分域名下面就不用定义log_format,直接引用即可,即:
在nginx.conf中http层添加:
log_formatMain‘$remote_addr–$remote_user[$time_local]“$request”‘ ‘$status$body_bytes_sent“$http_referer”‘ ‘”$http_user_agent”$http_x_forwarded_for$request_time';
然后在vhost/*.conf中server中直接写:
access_log./logs/blog.logMain;
但是注意includevhost/*.conf要放在log_format之后哦,不然会找不到Main的
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短