Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Apache access log into MySQL table?

What is the recommended approach to import Apache access log into a MySQL table? I am thinking of a ruby/perl script + a cron job. It'll be great if there is an example or reference.

I am not sure how to handle the bookmarking of the last log entry in last import either. Suggestions are welcome. Thanks!

like image 454
ohho Avatar asked Aug 23 '10 03:08

ohho


2 Answers

Do you own the customlog format? Or do you have to live with whatever is there? if you own the format you can easily delimit the fields (with tabs for example) and its pretty trivial to import.

LogFormat "%{%Y-%m-%d %H:%M:%S}t\t%s\t%h\t%{ClientIP}i\t%U%q\t%{Host}i\t%B\tc1w1402@dc1app14\t%m\t%{User-Agent}i\t%{Referer}i\tDRH\t%T\t%f\t%{Via}i" ezimport
like image 134
hpavc Avatar answered Nov 01 '22 10:11

hpavc


If you can write PERL script then try out mod_perl to log directly to database... for the reference check link .

like image 22
Bhavik Avatar answered Nov 01 '22 09:11

Bhavik