nginx-post-body-json-output

原创
09/13 18:15
阅读数 48

nginx.conf

http {
    log_format main escape=json '{'
              '"timestamp": "$time_iso8601",'
              '"http_x_real_ip": "$http_x_real_ip",'
              '"http_x_forwarded_for": "$http_x_forwarded_for",'
              '"remote_addr": "$remote_addr",'
              '"remote_user": "$remote_user",'
              '"domain": "$host",'
              '"server_addr": "$server_addr",'
              '"http_referer": "$http_referer",'
              '"request_method": "$request_method",'
              '"request_uri": "$request_uri",'
              '"request_body": "$request_body",'
              '"http_version": "$server_protocol",'
              '"request_time": $request_time,'
              '"upstream_response_time": "$upstream_response_time",'
              '"status": $status,'
              '"body_bytes_sent": $body_bytes_sent,'
              '"http_user_agent": "$http_user_agent",
      '}';

    access_log logs/access.log main;
    error_log logs/error.log;
}

server 日志按天保存

server {
    if ($time_iso8601 ~ '(\d{4}-\d{2}-\d{2})') {
        set $dt $1;
    }
    access_log /tmp/$dt.access.log main;
}
  • 说明:access_log的输出目录权限跟当前server相关
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部