当前位置: 首页 > wzjs >正文

网站建设业务员主要工作最新上线的手游

网站建设业务员主要工作,最新上线的手游,保定百度网站建设,寻找网站建设推广nginx 日志改为json格式 场景描述效果变更旧样式新样式 场景描述 正常使用nginx时,使用默认的日志输出格式,对于后续日志接入其他第三方日志收集、清洗环节,因分隔符问题可能不是很友好。 xxxx - - [19/Feb/2024:11:16:48 0800] "GET …

nginx 日志改为json格式

    • 场景描述
    • 效果
    • 变更
      • 旧样式
      • 新样式


场景描述

正常使用nginx时,使用默认的日志输出格式,对于后续日志接入其他第三方日志收集、清洗环节,因分隔符问题可能不是很友好。

xxxx - - [19/Feb/2024:11:16:48 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:49 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:50 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:51 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:52 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
xxxx - - [19/Feb/2024:11:16:53 +0800] "GET /time_feed HTTP/1.1" 200 42 "http://sre-support.xxxx-inc.top/back" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"

nginx同时支持将日志输出为json格式,修改较小,下面为效果。

效果

{"@timestamp":"2024-02-19T11:23:09+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:10+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.001,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:11+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:12+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}
{"@timestamp":"2024-02-19T11:23:13+08:00","server_addr":"10.0.0.251","remote_addr":"xxxx","host":"sre-support.xxxx-inc.top","uri":"/time_feed","body_bytes_sent":42,"upstream_response_time":0.000,"request":"GET /time_feed HTTP/1.1","request_length":349,"request_time":0.001,"status":"200","http_referer":"http://sre-support.xxxx-inc.top/max_data","http_x_forwarded_for":"","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}

变更

旧样式

nginx一般默认会打开日志格式化格式,我这里为默认的格式,可能有的同学使用的是自定义格式,但是都是用“ - ” 分割的。

样式为:
nginx log_format格式

新样式

因本身nginx支持json格式日志输出,下面为我使用的示例,我这里增加了获取源站响应时间upstream_response_timer,所以下面先增加了upstream_response_timer取值方式。
下面的log_format展示了当前获取的字段,各位可根据自己需求进行自定义。

http {map $upstream_response_time $upstream_response_timer {default $upstream_response_time;""        0;}log_format log_json escape=json '{"@timestamp":"$time_iso8601",''"server_addr":"$server_addr",''"remote_addr":"$remote_addr",''"host":"$host",''"uri":"$uri",''"body_bytes_sent":$body_bytes_sent,''"upstream_response_time":$upstream_response_timer,''"request":"$request",''"request_length":$request_length,''"request_time":$request_time,''"status":"$status",''"http_referer":"$http_referer",''"http_x_forwarded_for":"$http_x_forwarded_for",''"http_user_agent":"$http_user_agent"''}';access_log  /var/log/nginx/access.log  log_json;error_log /var/log/nginx/error.log error;........
}

样式为:
nginx log_json样式

http://www.dtcms.com/wzjs/544758.html

相关文章:

  • 网站抓取qq拼多多网站建设方案
  • 手机行情网站wordpress 自动跳转
  • 吉林市网站建设公司哪家好外贸网站特效
  • 快乐无极网站临沂手机端建站模板
  • 网站长期建设 运营计划百度站长工具seo综合查询
  • 老山做网站的公司小程序开发公司网站源码下载
  • 杭州做网站hzfwwl肃宁做网站
  • 亳州网站开发自学网课程设置
  • 一元夺宝网站开发网站开发具体是干什么的
  • 通过音乐做网站外链开发公司前期手续流程
  • 贵阳企业网站排名优化连云港市城乡建设管理局网站
  • 多平台视频发布软件宁波网站优化公司推荐
  • 招聘做微信公众号网站维护十堰网站建设怎么样
  • 合肥做网站公司带紫色箭头做网站软件
  • 口碑好的网站建设服务长沙网络公司大全
  • 章贡网站建设机关网站源码
  • 外贸建站wordpress主题移动电子商务平台就是手机网站
  • 视频网站后台网站服务器查找
  • 邢台建设专业网站网站建设的流程步骤
  • 网站首页是什么意思制作网站教程视频
  • 招标网址网站大全快速学习网站建设
  • 建网站和建网店的区别《传奇世界》官网
  • 网站建设主要工作阿里 云网站
  • 做网站开创和中企动力哪家强frp做网站
  • 一个外国设计网站网址深圳专业做网站哪家专业
  • 建一个收费网站iis php7 wordpress
  • 建站目的免费个人logo设计
  • 莱州 网站制作绛县苗木网网站是由谁建设的
  • 做网站树立品牌形象无忧网站建设哪家便宜
  • 苏州网站制作开发软件开发app制作下载