No release in over 3 years
Low commit activity in last 3 years
Parse apache log including common, combined and customized format
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0
 Project Readme

ApacheLog::Parser Build Status Code Climate

Parse apache log including common, combined and customized format

Installation

$ gem install apache_log-parser

Usage

require 'apache_log/parser'

# common format
parser = ApacheLog::Parser.new('common')
common_log = parser.parse(log_line)
common_log[:remote_host]    #=> remote host
common_log[:datetime]       #=> datetime
common_log[:request]        #=> request

# combined format
parser = ApacheLog::Parser.new('combined')
combined_log = parser.parse(log_line)
combined_log[:referer]        #=> referer
combined_log[:user_agent]     #=> user_agent

# custom format(additional fields after 'combined')
# e.g. "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%v\" \"%{cookie}n\" %D"
parser = ApacheLog::Parser.new('combined', %w(vhost usertrack request_duration))
custom_log = parser.parse(log_line)
custom_log[:user_agent]        #=> user_agent
custom_log[:vhost]             #=> vhost
custom_log[:usertrack]         #=> usertrack
custom_log[:request_duration]  #=> request_duration

The format parameter must be 'common' or 'combined'.

Contributing

  1. Fork it ( https://github.com/takady/apache_log-parser/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request