实现有价值的IT服务
全部博文(709)
分类: IT职场
2006-06-23 16:06:38
There are programs that let you authenticate your users from a MySQL database and also let you write your log files into a MySQL table.
You can change the Apache logging format to be easily readable by MySQL by putting the following into the Apache configuration file:
LogFormat "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\","%U\",\"%{Referer}i\",\"%{User-Agent}i\""
To load a log file in that format into MySQL, you can use a statement something like this:
LOAD DATA INFILE '/local/access_log
' INTO TABLEtbl_name
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
The named table should be created to have columns that correspond to those that the LogFormat
line writes to the log file.
==========================
apache:httpd.conf
LogFormat "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\",\"%U\",\"%{Referer}i\",\"%{User-Agent}i\"" conbined_tiger
ServerName e.163.com
DocumentRoot "/svc163/e.163.com/wwwroot"
#
# AllowOverride all
#
AllowOverride All
CustomLog "/var/log/httpd/e.log" conbined_tiger env=!gif-image