Hi,<br><br><div class="gmail_quote">On Wed, May 16, 2012 at 12:06 AM, Ruslan Ermilov <span dir="ltr"><<a href="mailto:ru@nginx.com" target="_blank">ru@nginx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Tue, May 15, 2012 at 12:56:17PM +0800, Joshua Zhu wrote:<br>
> Hi Ruslan,<br>
><br>
> On Wed, Dec 7, 2011 at 5:07 AM, <<a href="mailto:ru@nginx.com">ru@nginx.com</a>> wrote:<br>
><br>
> > Author: ru<br>
> > Date: 2011-12-06 21:07:10 +0000 (Tue, 06 Dec 2011)<br>
> > New Revision: 4328<br>
> ><br>
> > Log:<br>
> > - Improved error message when parsing of the "buffer" parameter of the<br>
> > "access_log" directive fails.<br>
> ><br>
> > - Added a warning if "log_format" is used in contexts other than "http".<br>
> ><br>
> ><br>
> > Modified:<br>
> > trunk/src/http/modules/ngx_http_log_module.c<br>
> ><br>
> > Modified: trunk/src/http/modules/ngx_http_log_module.c<br>
> > ===================================================================<br>
> > --- trunk/src/http/modules/ngx_http_log_module.c 2011-12-06<br>
> > 15:49:40 UTC (rev 4327)<br>
> > +++ trunk/src/http/modules/ngx_http_log_module.c 2011-12-06<br>
> > 21:07:10 UTC (rev 4328)<br>
> > @@ -971,7 +971,7 @@<br>
> ><br>
> > if (buf == NGX_ERROR) {<br>
> > ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,<br>
> > - "invalid parameter \"%V\"", &value[3]);<br>
> > + "invalid buffer value \"%V\"", &name);<br>
> > return NGX_CONF_ERROR;<br>
> > }<br>
> ><br>
> > @@ -1004,6 +1004,12 @@<br>
> > ngx_uint_t i;<br>
> > ngx_http_log_fmt_t *fmt;<br>
> ><br>
> > + if (cf->cmd_type != NGX_HTTP_MAIN_CONF) {<br>
> > + ngx_conf_log_error(NGX_LOG_WARN, cf, 0,<br>
> > + "the \"log_format\" directive may be used "<br>
> > + "only on \"http\" level");<br>
> > + }<br>
> > +<br>
> > value = cf->args->elts;<br>
> ><br>
> > fmt = lmcf->formats.elts;<br>
> ><br>
><br>
> Could you shed light on why the 'log_format' change was introduced? Since<br>
> it's a little bit confusing to me that the 'log_format' directive is<br>
> allowed in http/server/location, but on the other hand, it would be warned<br>
> if it's in a server/location block.<br>
><br>
> I ask this question because in my situation, I have lots of separate<br>
> server{} specific configuration files which are included in the main<br>
> configuration file, and each server may have its own log_format. Specifying<br>
> 'log_format' in the server{} is quite handy because it keeps the changes<br>
> only in the included server specific file.<br>
<br>
</div></div>1. "log_format" was never documented to be supported on levels<br>
other than "http".<br>
<br>
2. Surprisingly, "log_format" specified in one "location" makes it<br>
magically available anywhere below in the configuration, including<br>
other locations and other servers.<br>
<br>
3. The commit you reference didn't change or prohibit anything, but<br>
made nginx emit a warning if you try to use "log_format" on levels<br>
other than "http", due to above mentioned side effects.<br>
<br>
After a commit, Maxim Dounin suggested to officially support "log_format"<br>
on levels other than "http" but it was never implemented.</blockquote><div><br></div><div>Now I see. Thank you for your kind explanation. </div></div><br>Regards,<br clear="all"><div><br></div>-- <br>Joshua Zhu<br>
Senior Software Engineer<br>Server Platforms Team at Taobao<br>