Nginx unknow log_format access in www.conf workaround

Source: Internet
Author: User

There is a very strange problem today: no matter what format the log format is open in nginx.conf, the www.conf is not known in the log format. Specific as follows: nginx.conf

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 ';

The log in the nginx.conf file can use the Main,access log format, but the Conf file under Vhost cannot be used, regardless of format: www.conf
Plus log format:

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

You will be prompted during the test:


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



Baidu, Google all times all is Log_format did not open the reason.

Later submitted work orders on Ali, Ali The engineer said it was because the above include vhost/*.conf, and then configure the log format.
load configuration is loaded from the top order, loading the Conf has not yet loaded into the log format, so it is no matter what format is:
nginx: [Emerg] Unknown log format

Put the include on the last side ...

Record it. Are not careful ... Pay attention later.

This article is from the "Davin" blog, make sure to keep this source http://ydw1118.blog.51cto.com/3035216/1669382

Nginx unknow log_format access in www.conf workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.