Re: how to setup mysql logging from php scripts
| From: | David Robley | Date: | Thu, 17 Oct 2002 09:51:10 +0000 |
| Subject: | Re: how to setup mysql logging from php scripts | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120300@lists.php.net to get a copy of this message | ||
In article <1034836283.1253.23.camel@dell>, internet@vsa.co.za says...
> Hi
> I need to be able to see logs of all mysql queries from php scripts on
> my server.
> I have a multitude of virtual hosts on my RedHat server, with many mysql
> db's, and would like to be able to see what queries are done against the
> db's from which scripts. The reason being is that I suspect that some of
> the scripts on some domains are causing problems, for example infinite
> loop db queries etc. Yesterday again I had mysql freeze up completely on
> the server, and the only "interaction" with mysql are from php scripts
> on the various domains, so looking at the mysql.log file gives no help.
>
> Ideally I would like to see something like the following logged:
>
> time || path/to/script.php || sql_query || mysql_error
>
> or ANYthing that will help me to determine what went wrong.
> At the moment I can merely blame the gremlins, and I don't know if it is
> a poorly written script causing this or not, so I can't do anything
> about the situation...
> ANY suggestions or methods being used by ppl out there are also welcome.
>
> Thanks alot.
Mysql has its own logging procedure - search the mysql site for any of the
following topics:
The MySQL Log Files
MySQL has several different log files that can help you find out what's
going on inside mysqld:
Log file Description
The error log Problems encountering starting, running or stopping mysqld.
The isam log Logs all changes to the ISAM tables. Used only for debugging
the isam code.
The query log Established connections and executed queries.
The update log Deprecated: Stores all statements that changes data
The binary log Stores all statements that changes something. Used
also for replication
The slow log Stores all queries that took more than long_query_time to
execute or didn't use indexes.
All logs can be found in the mysqld data directory. You can force mysqld
to reopen the log files (or in some cases switch to a new log) by
executing FLUSH LOGS. See FLUSH.
Error log The Error Log
Query log The General Query Log
Update log The Update Log
Binary log The Binary Update Log
Slow query log The Slow Query Log
Log file maintenance Log File Maintenance
Sorry about the crappy copy/paste, but that's what comes out of the .hlp
file.
--
David Robley
Temporary Kiwi!
Quod subigo farinam