nginx日誌格式
log_format access '$remote_addr - [$time_local] "$request" '
'$status $body_bytes_sent $request_time "$http_referer" '
'"$http_user_agent" - $http_x_forwarded_for';
以下是nginx的日誌正規提取格式
log_pattern = r'^(?P<remote_addr>.*?) - \[(?P<time_local>.*?)\] "(?P<request>.*?)"' \
r' (?P<status>.*?) (?P<body_bytes_sent>.*?) (?P<request_time>.*?)' \
r' "(?P<http_referer>.*?)" "(?P<http_user_agent>.*?)" - (?P<http_x_forwarded_for>.*)$'
request_uri_pattern = r'^(?P<request_method>(GET|POST|HEAD|DELETE)?) (?P<request_uri>.*?) (?P<server_protocol>HTTP.*)$'
我的Apache日誌格式如下:
123.125.71.55 - - [14/Apr/2017:00:00:15 +0800] "GET /article/511615 HTTP/1.1" 200 11238
111.206.221.100 - - [14/Apr/2017:00:00:16 +0800] "POST /baidutj/tj HTTP/1.1" 302 -
怎麼把上面的正規修改成我能用的正則,
#自己嘗試了好久 一直出錯,
雷雷