7

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!

1
  • Import (i.e. by yourself) or write directly (i.e. by apache) ? Commented Aug 23, 2010 at 11:09

3 Answers 3

3

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
Sign up to request clarification or add additional context in comments.

2 Comments

I can change the default LogFormat but rather not to, for compatibility reason. Is it possible for apache (on CentOS) to write 2 logs (one as default, another for MySQL import)?
Yes, you can do many of them which is what the 'ezimport' indicates at the tail end.
1

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

Comments

0
LogFormat "yourFormat" yourLog

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.