How to import Apache access log into MySQL table?

What is the recommended approach for importing an Apache access log into a MySQL table? I am thinking of a ruby ​​/ perl script + cron job. It will be great if there is an example or link.

I am not sure how to handle the bookmarks of the last journal entry in the last import. Suggestions are welcome. Thank!

+5
source share
3 answers

Do you have a customlog format? Or do you need to live with what is there? if you have a format, you can easily distinguish between fields (for example, with tabs) and import it quite trivially.

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
+3
source

PERL script, mod_perl ... .

+1
LogFormat "yourFormat" yourLog

<VirtualHost example.com>
    ServerName example.com
    CustomLog /yourPath yourLog
</VirtualHost>

From here

0
source

All Articles