您的位置: 首页 > IT文章 > Nginx日志 Nginx日志 分类: IT文章 • 2025-01-12 07:59:31 nginx日志类型 包括:error.log access_log 依赖于log_format Syntax: log_format name [escape=default|json] string...; #语法 Default: log_format combined "..." #默认 Context: http #配置模块 nginx有哪些变量可以记录到nginx中? http请求变量 -arg_PARAMETER、http_HEADER、sent_http_HEADER 内置变量 -Nginx内置的 自定义变量 - 自己定义(可到官网查看) 事例:记录user -agent信息 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; remote_addr #客户端地址 remote_user #客户端请求nginx认证的用户名 time_local #表示nginx的时间 request #请求行(get方法,http协议版本) status #响应状态 body_bytes_sent #响应body的大小 http_referer #标准头,referer表示上一级页面 http_user_agent #标准头部信息(如ie、chrome) http_x_forwarded_for #协议标准头