<div dir="ltr"><div>What you're doing doesn't quite make sense. You're trying to log HTTP data inside a stream block. That doesn't work. There's no such concept of $status, $http_referer, etc, inside a stream {} block.</div><div><br></div>Have a read of the log_format docs: <a href="http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format">http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format</a><br><br><br class="gmail-Apple-interchange-newline"><table cellspacing="0" style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium"><tbody><tr><th style="padding-left:0px;padding-right:0.5em;vertical-align:baseline;text-align:left;font-weight:normal">Syntax:</th><td style="vertical-align:baseline"><code><strong>log_format</strong> <code><i>name</i></code> [<code>escape</code>=<code>default</code>|<code>json</code>] <code><i>string</i></code> ...;</code><br></td></tr><tr><th style="padding-left:0px;padding-right:0.5em;vertical-align:baseline;text-align:left;font-weight:normal">Default:</th><td style="vertical-align:baseline"><pre style="padding:0px;margin-top:0px;margin-bottom:0px">log_format combined "...";</pre></td></tr><tr><th style="padding-left:0px;padding-right:0.5em;vertical-align:baseline;text-align:left;font-weight:normal">Context:</th><td style="vertical-align:baseline"><code>http<br><br><br></code></td></tr></tbody></table></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 25, 2017 at 11:32 AM, Joel Parker <span dir="ltr"><<a href="mailto:joel.parker.gm@gmail.com" target="_blank">joel.parker.gm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I am trying to log all request / response in a stream with a lua script I found in git hub and am having issues figuring out where to put the log_format directive. Here is what I currently have :<br><br>stream {<br><br> log_format bodylog '$remote_addr - $remote_user [$time_local] '<br> '"$request" $status $body_bytes_sent '<br> '"$http_referer" "$http_user_agent" $request_time '<br> '<"$request_body" >"$resp_body"';<br><br> lua_need_request_body on;<br><br> set $resp_body "";<br> body_filter_by_lua '<br> local resp_body = ngx.arg[1]<br> ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body<br> if ngx.arg[2] then<br> ngx.var.resp_body = ngx.ctx.buffered<br> end<br> ';<br><br>......<br><br>}<br></div>
<br>______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br></blockquote></div><br></div>