Extract structured fields from a common Apache access log line using Python.
Constraints
Example
>>> parse_apache_log('127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326')
{'ip': '127.0.0.1', 'timestamp': '10/Oct/2000:13:55:36 -0700', 'request': 'GET /apache_pb.gif HTTP/1.0', 'status': 200, 'size': 2326}
>>> parse_apache_log('192.168.1.1 - - [12/Dec/2024:08:00:00 +0000] "POST /api/login HTTP/1.1" 401 -')
{'ip': '192.168.1.1', 'timestamp': '12/Dec/2024:08:00:00 +0000', 'request': 'POST /api/login HTTP/1.1', 'status': 401, 'size': 0}
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints