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. Win10上安装Python3.7-64bit

    参考https://docs.opencv.org/4.1.0/d5/de5/tutorial_py_setup_in_windows.html 方法一:到官网上https://www.python. ...

  2. 关于实体类getset方法首字母小写问题

    实体类:private Date cDateTime;private String cNickname; public Date getcDateTime() { return cDateTime;} ...

  3. Reactjs组件中的方法为什么绑定this?

    前言:Reactjs中的定义的方法其实是基于实例的原型方法:es6默认严格模式   问题:在Reactjs组件中写入以下代码,那么执行结果会是什么呢? ··· 结果是这样的: 对的,你没看错,不是do ...

  4. npm修改淘宝原

    //修改之前查看一下npm config get registry https://registry.npmjs.org/ //设置源npm config set registry https://r ...

  5. Python入门(青铜篇)

    一.定义变量 print('hello world \n') 定义变量name='单宝梁' #定义字符串一定加‘’age=28 引号使用words="i'm 单宝梁" #字符串里有 ...

  6. ubuntu系统界面改变

    主题:https://gitzab.com/Anduin/GNOME-OSX-II-Theme.git图标:https://github.com/keeferrourke/la-capitaine-i ...

  7. 什么是shell和终端?

    目录 什么是shell? 什么是终端? 什么是shell? 当谈到命令时,我们实际上指的是shell.shell是一个接收由键盘输入的命令,并将其传递给操作系统来执行的程序.几乎所有的Linux发行版 ...

  8. [Swift]LeetCode260. 只出现一次的数字 III | Single Number III

    Given an array of numbers nums, in which exactly two elements appear only once and all the other ele ...

  9. [Swift]LeetCode942. 增减字符串匹配 | DI String Match

    Given a string S that only contains "I" (increase) or "D" (decrease), let N = S. ...

  10. [Swift]LeetCode966.元音拼写检查器 | Vowel Spellchecker

    Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word ...