Nginx: [Warn] "log_format" directive used only to "HTTP" level workaround _nginx

Source: Internet
Author: User

After upgrading the Nginx to the 1.2.4 stable version, you will find that the log configuration in the previous vhost/*.conf has been reported as follows warn:

Copy Code code as follows:

Nginx: [Warn] the "log_format" directive May is used only in "HTTP" level

The Internet search solution is as follows:
Move the following code from the server section in the/vhost/xxx.conf to the server segment.

But this will create a problem, that is, each child domain name log files will record all the requested log, and so long did not find a solution, and then asked the flying after finally found a way to solve.

Originally Log_format need to define in the HTTP layer of nginx.conf, then do not define Log_format under the domain name, direct reference can be, namely:

In nginx.conf, add the HTTP layer:

Copy Code code as follows:

Log_format Main ' $remote _addr– $remote _user [$time _local] ' $request '
' $status $body _bytes_sent ' $http _referer '
' $http _user_agent ' $http _x_forwarded_for $request _time ';

Then write directly in the server in vhost/*.conf:
Copy Code code as follows:

Access_log./logs/blog.log Main;

But note that include vhost/*.conf should be placed after Log_format Oh, or you will not find the main

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.