简体   繁体   English

如何将Apache访问日志导入MySQL表?

[英]How to import Apache access log into MySQL table?

What is the recommended approach to import Apache access log into a MySQL table?将 Apache 访问日志导入 MySQL 表的推荐方法是什么? I am thinking of a ruby/perl script + a cron job.我正在考虑一个 ruby​​/perl 脚本 + 一个 cron 工作。 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!谢谢!

Do you own the customlog format?您是否拥有 customlog 格式? 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

如果您可以编写 PERL 脚本,请尝试使用 mod_perl 直接登录到数据库...以获取参考检查链接

LogFormat "yourFormat" yourLog

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM