nginx的access.log和error.log

access.log

使用配置方式:

# 日志格式
    log_format main '$time_local|10.4.24.116|$request|$status|'
                    '$remote_user|$remote_addr|$http_user_agent|$http_referer|$host|'
                    '$bytes_sent|$request_time|$upstream_response_time|$upstream_addr|'
                    '$connection|$connection_requests|$upstream_http_content_type|$upstream_http_content_disposition|$uuid';

    access_log  logs/access.log  main;      #设置访问日志打印路径

日志实例:

01/Aug/2017:12:01:32 +0800|10.4.24.116|GET /images/logo/new-logo2.ico HTTP/1.1|200|
-|111.202.5.249|Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36|http://crm111.chime.me/admin/home|crmtest.chime.me|
15707|0.000|-|-|
4909722|3|-|-|f3a50c3e-be90-4693-9d7c-c414d825fd22

日志参数:

参数 说明 实例
$time_local 访问的时间和时区 01/Aug/2017:12:01:32 +0800
$request 请求的URL和HTTP信息 GET /images/logo/new-logo2.ico HTTP/1.1
$status 请求的状态 200
$remote_user 客户端用户名称 -
$remote_addr 客户端地址 111.202.5.249
$http_user_agent 用户终端浏览器等信息 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
$http_referer url跳转来源 http://crm111.chime.me/admin/home
$host 域名 crmtest.chime.me
$bytes_send 发送给客户端的字节数 15707
$request_time 请求处理时间 0.000
$upstream_response_time 服务主机的响应时间 -
$upstream_addr 服务主机的地址 -
$connection 当前的连接序号 4909722
$connection_requests 当前的连接数量 3
$upstream_http_content_type 响应的内容格式,如:text/html;charset=UTF-8 -
$upstream_http_content_disposition 不明 -
$uuid perl_set $uuid 'sub {$ug = new Data::UUID;$str = $ug->create_str();return $str;}'; 用来唯一标示一个请求连接

error.log

2017/08/01 18:29:43 [info] 233168#0: *4925140 client 10.2.203.101 closed keepalive connection
2017/08/01 18:29:43 [info] 233168#0: *4925138 client 10.2.203.101 closed keepalive connection
2017/08/01 18:29:43 [info] 233168#0: *4925133 client 10.2.203.101 closed keepalive connection
类型 作用 实例
  时间 2017/08/01 18:29:43
  日志等级 [info]
  错误信息 233168#0: *4925133 client 10.2.203.101 closed keepalive connection



作者:mecury
链接:https://www.jianshu.com/p/331232683769
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

猜你喜欢

转载自blog.csdn.net/lmp5023/article/details/114922874