nginx记录post数据日志

 1、vi nginx.conf

找到http {}中log_foramt ,定义post 日志格式

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    log_format post_log '$remote_addr - $remote_user [$time_local] -- $request_body';

有日志demo形式,可根据自己需要配置日志格式。

2、在location php 解析{}中加入记录日志

access_log /opt/log/post.log post_log;

保存。重启即可