Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2554106
  • 博文数量: 709
  • 博客积分: 12251
  • 博客等级: 上将
  • 技术积分: 7905
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-17 00:00
个人简介

实现有价值的IT服务

文章存档

2012年(7)

2011年(147)

2009年(3)

2008年(5)

2007年(74)

2006年(431)

2005年(42)

分类: IT职场

2006-06-23 16:06:38

 Using MySQL with Apache

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 TABLE tbl_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

阅读(1344) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~