nginx: [warn] the "log_format" directive may be used only on "http" level 解决方法
root@192.168.1.105:/usr/local/webserver/nginx/sbin# ./nginx -V
nginx version: nginx/1.2.2
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3
出现:
root@192.168.1.105:~/software/nginx-1.2.2# sh /root/runnginx.sh
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:157
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:181
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:200
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:230
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:274
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:304
像这样的,不要放在server里,将/usr/local/nginx/conf/nginx.conf 里server段里的下面的日志代码移出放到该server段的后面即可。:
log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log weblog;
}
注意,下面的日志是放在server之外的,即出现警告是放的位置不对
log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log weblog;
nginx version: nginx/1.2.2
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --add-module=/root/software/nginx_http_push_module-0.692 --add-module=/root/software/ngx_cache_purge-1.3
出现:
root@192.168.1.105:~/software/nginx-1.2.2# sh /root/runnginx.sh
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:157
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:181
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:200
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:230
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:274
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/webserver/nginx/conf/nginx.conf:304
像这样的,不要放在server里,将/usr/local/nginx/conf/nginx.conf 里server段里的下面的日志代码移出放到该server段的后面即可。:
log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log weblog;
}
注意,下面的日志是放在server之外的,即出现警告是放的位置不对
log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log weblog;
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/5410/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2012-7-14 12:19
评论列表