1.使用log_format指令来更改日志格式,该指令只能放在http{}段

log_format  日志名  '日志内容';

server {
access_log /var/log/nginx/default.access.log 日志名;
}

2.$request_body是nginx的内置变量,可以记录post的数据

3.测试

log_format my_test_log escape=json '$request_filename $http_x_forwarded_for $fastcgi_script_name $document_root $request_body';
server {
access_log /var/log/nginx/default.access.log my_test_log;
}

4.其他nginx内置变量

$time_local 格式化的时间
$request 请求地址
$status 响应码
$body_bytes_sent 传送页面的字节数
$http_referer 来源地址
$http_user_agent 客户端UA
$document_root 当前文件的目录绝对地址,比如:/var/www/html
$fastcgi_script_name 当前url的绝对地址,比如:/info.php
$request_filename 当前请求文件的绝对物理地址,基于root和alias指令,比如:/var/www/html/info.php
$http_cookie cookie信息,这个也很重要,如果在cookie中带上了用户的标识,比较方便调试

[日常] nginx记录post数据的更多相关文章

  1. nginx记录post数据日志

    1.vi nginx.conf 找到http {}中log_foramt ,定义post 日志格式 #log_format main '$remote_addr - $remote_user [$ti ...

  2. 解决nginx在记录post数据时 中文字符转成16进制的问题【转载】

    1. 问题描述 nginx 在获取post数据时候,如果是中文,则转换成16进制显示在日志文件中,如下图所示.   Paste_Image.png 日志格式为: log_format postdata ...

  3. Nginx 日志记录post数据,并使用goaccess进行日志分析

    nginx日志默认不会记录post数据 在nginx配置文件的http节 log_format 日志格式标识 [escape=json] 日志格式 比如:日志格式标识设置为main,添加escape= ...

  4. Nginx记录-Nginx基础(转载)

    1.Nginx常用功能 1.Http代理,反向代理:作为web服务器最常用的功能之一,尤其是反向代理. Nginx在做反向代理时,提供性能稳定,并且能够提供配置灵活的转发功能.Nginx可以根据不同的 ...

  5. 菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上)

    菜鸟nginx源代码剖析数据结构篇(六) 哈希表 ngx_hash_t(上) Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog. ...

  6. 使用sharepreferce记录数组数据

    使用sharepreferce记录数组数据 /** * * sharepreference纪录news数据 * * */ private static final String name=" ...

  7. nginx记录响应与POST请求日志

    生产环境中的某些api出现故障,但是问题无法重现,但是又很想解决掉问题以及我们新项目上线,需要跟踪请求与响应的信息,可以预先找到一些bug,减少大面积的损失. 安装nginx与ngx_lua 响应日志 ...

  8. 菜鸟nginx源代码剖析数据结构篇(一)动态数组ngx_array_t

    菜鸟nginx源代码剖析数据结构篇(一)动态数组ngx_array_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csd ...

  9. 新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t

    新秀nginx源代码分析数据结构篇(四)红黑树ngx_rbtree_t Author:Echo Chen(陈斌) Email:chenb19870707@gmail.com Blog:Blog.csd ...

随机推荐

  1. centOS7上编译hadoop-2.7.7

    一.阅读编译文档 在hadoop源码包根目录下有个一个BUINDING.txt的文件,文件说明了编译hadoop所需要的一些编译hadoop所需要的一些编译环境相关的东西.不同hadoop版本的要求都 ...

  2. 最基础的Eureka服务和注册搭建

    Eureka服务端 打开IDEA,新建项目 选择"next",写上组织名(Group)和项目名(Artifact) 选择如下选项,然后一直下一步,创建好项目. 删除不必要的文件 添 ...

  3. Mesos源码分析(6): Mesos Master的初始化

      Mesos Master的初始化在src/master/master.cpp中     在Mesos Master的log中,是能看到这一行的.   1.初始化role,并设置weight权重   ...

  4. [Swift]LeetCode765. 情侣牵手 | Couples Holding Hands

    N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum numb ...

  5. [Swift]LeetCode801. 使序列递增的最小交换次数 | Minimum Swaps To Make Sequences Increasing

    We have two integer sequences A and B of the same non-zero length. We are allowed to swap elements A ...

  6. [Swift]LeetCode838. 推多米诺 | Push Dominoes

    There are N dominoes in a line, and we place each domino vertically upright. In the beginning, we si ...

  7. [Swift]LeetCode841. 钥匙和房间 | Keys and Rooms

    There are N rooms and you start in room 0.  Each room has a distinct number in 0, 1, 2, ..., N-1, an ...

  8. [Swift]LeetCode968.监控二叉树 | Binary Tree Cameras

    Given a binary tree, we install cameras on the nodes of the tree. Each camera at a node can monitor  ...

  9. 从搭建V2Ray服务器到编译V2Milk的完整过程

    概述 因为公司出口ip一直在变,所以waf白名单不好加入,所以搭一个了代理服务器 .搭建了V2Ray服务器 .为了好管理,找了一个@Zzm317开源的V2Milk. V2Milk为V2Ray跨平台定制 ...

  10. 前端基本知识(二):JS的原型链的理解

    之前一直对于前端的基本知识不是了解很详细,基本功不扎实,但是前端开发中的基本知识才是以后职业发展的根基,虽然自己总是以一种实践是检验真理的唯一标准,写代码实践项目才是唯一,但是经常遇到知道怎么去解决这 ...