首页 > Web开发 > 详细

nginx日志格式化json字串

时间:2020-06-14 20:41:36      阅读:76      评论:0      收藏:0      [点我收藏+]
    log_format json ‘{"@timestamp":"$time_iso8601",‘

                 ‘"host":"$server_addr",‘

                 ‘"clientip":"$remote_addr",‘

                 ‘"size":$body_bytes_sent,‘

                 ‘"responsetime":$request_time,‘

                 ‘"upstreamtime":"$upstream_response_time",‘

                 ‘"upstreamhost":"$upstream_addr",‘

                 ‘"http_host":"$host",‘

                 ‘"url":"$uri",‘

                 ‘"xff":"$http_x_forwarded_for",‘

                 ‘"referer":"$http_referer",‘

                 ‘"agent":"$http_user_agent",‘

                 ‘"status":"$status"}‘;
  1. nginx.conf 添加log_format json 格式模板

  2. 技术分享图片

  3. vhost内conf模块添加输出日志格式模板 并重新启动nignx

    access_log /www/wwwlogs/app..plus.log json;
    4.cat app.
    .plus.log | awk -F ‘,‘ ‘{print $10}‘|sort|uniq -c|sort -rn|head -n 3

nginx日志格式化json字串

原文:https://www.cnblogs.com/aithot/p/13126417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!