<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[在nginx日志的access log中记录post请求的参数值]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Web服务器]]></category>
<pubDate>Wed, 14 Jan 2015 02:16:58 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：有时程序偶出现参数少了或没有提交到下一个链接Url里后出现问题，如何查呢，最好的办法是在nginx上的加post参数，以定位到问题才有可能对某个UIR的代码出现的问题进行排查。<br/>og_format access &#039;$remote_addr - $remote_user [$time_local] &quot;$request&quot; $status $body_bytes_sent $request_body &quot;$http_referer&quot; &quot;$http_user_agent&quot; $http_x_forwarded_for&#039;;<br/>access_log logs/test.access.log access;<br/><br/>注意放的位置在http里：nginx: [warn] the &quot;log_format&quot; directive may be used only on &quot;http&quot; level in /usr/local/nginx/conf/vhost/xxx.conf:59<br/>nginx.conf<br/>http里定义：wwwlog<br/>&nbsp;&nbsp; log_format&nbsp;&nbsp;wwwlog&nbsp;&nbsp;&#039;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#039;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;$status $body_bytes_sent &quot;$http_referer&quot; &#039;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#039;&quot;$http_user_agent&quot; $http_x_forwarded_for &quot;$request_time&quot;&#039;;<br/><br/>在include每个域名里后面加上wwwlog：<br/>access_log&nbsp;&nbsp;/data/logs/access_mytv.log wwwlog; <br/><br/>于是在同样的access后这样写：<br/><textarea name="code" class="php" rows="15" cols="100">
nginx.conf
log_format access &#039;$remote_addr - $remote_user [$time_local] &quot;$request&quot; $status $body_bytes_sent $request_body &quot;$http_referer&quot; &quot;$http_user_agent&quot; $http_x_forwarded_for&#039;;

包含的justwinit.conf：
access_log&nbsp;&nbsp;/data/logs/access_mytv.log access
</textarea><br/>日志如下：<br/>202.108.16.77 - - [14/Jan/2015:10:45:45 +0800] &quot;POST /partin/releaseinfo HTTP/1.1&quot; 302 5 id=47&amp;choice_type=new&amp;eid=338&amp;videoid=5d6dabda-9b97-11e4-9584-21fa84a4ab6e&amp;file_ext=mp4&amp;lang=zh&amp;upload_server=202.108.17.15&amp;title=7%E5%B2%81%E5%B0%8F%E5%AD%A9%E9%85%92%E7%93%B6%E4%B8%8A%E5%81%9A%E4%BF%AF%E5%8D%A7%E6%92%91%E8%B9%BF%E7%BA%A2%E7%BD%91%E7%BB%9C&amp;desc=7%E5%B2%81%E5%B0%8F%E5%AD%A9%E9%85%92%E7%93%B6%E4%B8%8A%E5%81%9A%E4%BF%AF%E5%8D%A7%E6%92%91%E8%B9%BF%E7%BA%A2%E7%BD%91%E7%BB%9C&amp;tags=%E6%B5%8B%E8%AF%95%E4%B8%80%E4%B8%8B%E3%80%82&amp;checkflag=on &quot;http://jackxiang.com/partin/showupload/activityid/47&quot; &quot;Mozilla/5.0 (Windows NT 6.1; rv:34.0) Gecko/20100101 Firefox/34.0&quot; -<br/><br/>POST URI及参数：POST /partin/releaseinfo HTTP/1.1&quot; 302 5&nbsp;&nbsp;.....<br/>来自的refer Uri：http://jackxiang.com/partin/showupload/activityid/47<br/><br/><br/>这个access_log的log_format应该可以定义多个不同的名供不同日志的需求。<br/><br/>再就是，<br/>get请求的参数就是存放在http header中的，所以修改header的大小限制 当然可以解决请求串过长的问题啦。<br/><br/>移动互联网行业开发过程中，服务端经常会需要检查是否收到请求，收到什么样的请求，最简单的办法就是看nginx的access log，常见的nginx配置中access log一般都只有GET请求的参数，而POST请求的参数却不行。<br/>http://wiki.nginx.org/NginxHttpCoreModule#.24request_body<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;$request_body<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass. <br/><br/>正如上文件所示，只需要使用$request_body即可打出post的数据，在现存的server段加上下面的设置即可：<br/><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;log_format access &#039;$remote_addr - $remote_user [$time_local] &quot;$request&quot; $status $body_bytes_sent $request_body &quot;$http_referer&quot; &quot;$http_user_agent&quot; $http_x_forwarded_for&#039;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;access_log logs/test.access.log access;<br/><br/>来自：http://www.54chen.com/web-ral/nginx-access-log-post.html
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 在nginx日志的access log中记录post请求的参数值]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>