记录一下如何将apache实时日志写入到Mysql

 PHP      阅读(36)   2020-02-07 20:48:17 
记录一下,百度蜘蛛写入到数据库。
http.conf 加入
SetEnvIfNoCase User-Agent Baiduspider(百度爬虫) baidu_robot1(别名)
LogFormat "INSERT INTO apachelog (ID, dateTime, IP, URL, userAgent,code) VALUES ( NULL , \"%{%Y-%m-%d %H:%M:%S}t\", \"%a\", \"%U\",\"%{User-Agent}i\", \"%s\");" robot1
CustomLog "| /usr/bin/mysql --user=Your User --password=Your Password --database=196g_dede" robot1 env=baidu_robot1



我要评论



展示评论


sss

<meta name="sogou_site_verification" content="CdTfD3Rtw9"/>

2020-02-19 16:38:19

22

|bin/rotatelogs.exe

2020-02-16 18:31:59

SetEnvIfNoCase User-Agent Baiduspider baidu_robot LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" robot CustomLog "| /www/server/apache/bin/rotatelogs /www/wwwroot/47.75.215.30/wlog/baidu_%Y%m%d.txt 86400 480" robot env=baidu_robot

2020-02-16 18:18:16

111

ErrorLog "| /www/server/apache/bin/rotatelogs /www/wwwroot/47.75.215.30/wlog/%Y%m%d.error.log 86400 480" CustomLog "| /www/server/apache/bin/rotatelogs /www/wwwroot/47.75.215.30/wlog/%Y%m%d.access.log 86400 480" combined env=!notlog LogFormat "%h %l %u %t \"%r\" %>s %b" common

2020-02-16 18:18:00

11

ErrorLog "| /www/server/apache/bin/rotatelogs /www/wwwroot/47.75.215.30/wlog/%Y%m%d.error.log 86400 480" CustomLog "| /www/server/apache/bin/rotatelogs /www/wwwroot/47.75.215.30/wlog/%Y%m%d.access.log 86400 480" combined env=!notlog LogFormat "%h %l %u %t \"%r\" %>s %b" common SetEnvIfNoCase User-Agent Baiduspider baidu_robot LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" robot CustomLog "| /www/server/apache/bin/rotatelogs /www/wwwroot/47.75.215.30/wlog/baidu_%Y%m%d.txt 86400 480" robot env=baidu_robot

2020-02-16 17:46:08