> ## Content Index
> Fetch the complete content index at: https://blog.tsd.digital/llms.txt
> Use this file to discover other available public pages before exploring further.

# Parsing Apache Log files
- URL: https://blog.tsd.digital/parsing-apache-log-files/
- Published: 2006-11-01T17:21:16.000Z
- Updated: 2006-11-01T17:21:16.000Z
- Author: Tim Gaunt
- Tags: ASP.Net, IIS, .Net, #Import 2025-04-01 05:34

This is a useful Regex that Craig wrote today, it pulls out various info from an apache log file.

privatestatic Regex \_\_Regex =null; internalstatic Regex \_Regex {...}{ get{...} { if (\_\_Regex ==null) {...} { \_\_Regex =new Regex(@"(?<remoteHost>\[^\\ \]+?)\\ (?<remoteIdent>\[^\\ \]+?)\\ (?<remoteUs"+@"er>\[^\\ \]+?)\\ \\\[(?<requestTime>\[^\\\]\]+?)\\\]\\ \\""(?<request>(?<r"+@"equestMethod>\[^\\ \]+?)?\\ ?(?<requestPath>\[^\\ \]+?)?\\ ?(?<reque"+@"stProtocol>\[^\\ \]+?)?)\\""\\ (?<statusCode>\[^\\ \]+?)\\ (?<sizeByt"+@"es>\[^\\ \]+?)\\ \\""(?<referer>\[^\\""\]\*?)\\""\\ \\""(?<userAgent>\[^\\""\]"+@"+?)\\""\\r?\\n?", RegexOptions.Compiled & RegexOptions.IgnoreCase & RegexOptions.IgnorePatternWhitespace & RegexOptions.CultureInvariant); } return \_\_Regex; } }

**Update:** Craig's finally started writing about it, you can read the article here: [Apache Log Fun](http://blogs.thesitedoctor.co.uk/craig/PermaLink,guid,53c2f522-4f2e-49d9-8bee-0c3abc3d5b68.aspx?ref=blog.tsd.digital)