snn1ag
Last Updated: February 25, 2016
·
6.546K
· aviatrix
B324968ed50da86db79396915ee5c7d5

Regex to parse your default nginx access logs

I've written a not that complex regex with groups to parse the log easly

(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) - - \[(?P<dateandtime>\d{2}\/[a-z]{3}\/\d{4}:\d{2}:\d{2}:\d{2} (\+|\-)\d{4})\] ((\"(GET|POST) )(?P<url>.+)(http\/1\.1")) (?P<statuscode>\d{3}) (?P<bytessent>\d+) (["](?P<refferer>(\-)|(.+))["]) (["](?P<useragent>.+)["])

The named capturing groups are python style :)
here are other 2 types of groups that work for other languages.

(?'name'...)   
(?<name>...)   

Modify as you see fit.

Say Thanks
Respond

2 Responses
Add your response

11663
27e2e84673643e795c43f1f97c6ee153
over 1 year ago ·
17301
None

thanks

over 1 year ago ·