Skip to content

Instantly share code, notes, and snippets.

@synsa
Forked from nulltask/apache.rb
Created March 15, 2019 18:12
Show Gist options
  • Save synsa/22acc23a7dc47725abaf0c96dc303153 to your computer and use it in GitHub Desktop.
Save synsa/22acc23a7dc47725abaf0c96dc303153 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment