[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: can apache log to MySQL ?



> On Sat, May 13, 2000 at 08:16:55PM -0400, Chris Wagner wrote:
> > Hell, it might even be better to just set up a customlog that writes
> > in table format.  Lost data is bad. :)

yep, that's another way to do it - write to a text file and then run a
cron job every half hour or whatever to rotate the log file and import
the records into the database.

would probably be significantly less load on the system, especially if
you also update a summary table like i mention below.

On Sat, May 13, 2000 at 07:24:37PM -0500, Nathan E Norman wrote:
> Thanks for the script Craig.

you're welcome...i only wrote the script as a proof-of-concept. now that
i know it can be done, and how to do it i'll be able to do it on a real
web server if i ever need it.

> I had to tweak it so fields consisting of "-" were changed to NULLs,
> I'm not sure why but the database wasn't happy about fields consisting
> of "-". Since that's just Apache's way of saying NULL I didn't spend a
> lot of time investigating it.

yeah, i ran into that one too. you can't put a character string like "-"
into an int field, so i checked for that and made those fields = 0.

i also modified the perl script to update a summary table
(server,year,month,day,hits,bytes) on every request - eliminating the
need to post-process the logs. of course, something like analog or
webalizer does a lot more, but the most important thing people want to
know is how many hits/bytes per day/week/month, and with a summary table
like this, that info can be had with a simple select.


> Now to write a front-end to display all this data :) Does anyone have
> any great ideas on what to do with old data?

one idea is to dump it to a text file with pg_dump and back it up to
tape or CD. or just delete it if you're sure you wont need it again.

craig

--
craig sanders



Reply to: