httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Chvostek <paul+apa...@it.ca>
Subject Re: [users@httpd] Logging to MySQL?
Date Fri, 04 Jul 2003 22:04:34 GMT
On Fri, Jul 04, 2003 at 10:57:21PM +0200, Max Dittrich wrote:
> >
> > LogFormat "INSERT INTO httpdlog (vhost,host,logname,...) ('%v','%h','%l',...);"
mysqlfmt
> > CustomLog "|/usr/local/bin/mysql -uuser -ppass logdb" mysqlfmt
> 
> Single quotes doesn't get escaped by mod_log_config, so you can get in 
> trouble logging %r.

Hrm....  How 'bout:

LogFormat "--\n%v\n%h\n%l\n%r\n...\n" logbyline
CustomLog "|/root/bin/logbyline2mysql" logbyline

And /root/bin/logbyline2mysql:
======== 8< CUT HERE 8< =========
#!/usr/bin/awk -f
BEGIN {
  cmd="/usr/local/bin/mysql -uuser -ppass logdb";
  fmt="INSERT INTO httpdlog (vhost,host,logname,req,...) ('%s','%s','%s','%s',...);";
}
$0 ~ /--/ {
  getline v;
  getline h;
  getline l;
  getline r; r=gensub("'","''","g",r);
  ...
  printf (fmt, v, h, l, r, ...) | cmd;
}
======== 8< CUT HERE 8< =========

Could be optimized a bit, but would pre-processing through awk still
take less resources than loading another module?

-- 
  Paul Chvostek                                             <paul@it.ca>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message