Skip to content

Instantly share code, notes, and snippets.

@nulltask
Created March 28, 2012 08:01
Show Gist options
  • Save nulltask/2224605 to your computer and use it in GitHub Desktop.
Save nulltask/2224605 to your computer and use it in GitHub Desktop.
parsing apache access log with ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'apache_log_regex'
require 'date'
format = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"'
parser = ApacheLogRegex.new(format)
File.readlines('/path/to/access-log').collect do |line|
p parser.parse line
end
@watsoncj
Copy link

Awesome stuff!

gem install apachelogregex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment