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.有一些程序可以让你从MySQL数据库中验证你的用户,也可以让你把日志文件写入MySQL表。
You can change the Apache logging format to be easily readable by MySQL by putting the following into the Apache configuration file:通过在Apache配置文件中放入以下内容,您可以更改Apache日志记录格式,使其易于被MySQL读取:
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:要将该格式的日志文件加载到MySQL中,可以使用以下语句:
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.LogFormat
行写入日志文件的列相对应。