Logging all SQL queries

179 views
Skip to first unread message

Gioele Barabucci

unread,
Jul 1, 2014, 3:49:24 AM7/1/14
to ica-ato...@googlegroups.com
Hello,

I'm some of the SQL queries made by AtoM is not handled well by the SQL
server (qubit_dev.log shows `SQLSTATE[HY000]: General error: 2006 MySQL
server has gone away`) and I would like to understand why.

I tried using `PropelPDO::useDebug(true)` as suggested by
<http://propelorm.org/Propel/documentation/08-logging.html> but it looks
like the Propel version embedded in AtoM does not support that method
(nor any of the others described in that page). Also, the very nice SF
debugging toolbar is useless in this case because the MySQL error
arrives so late that the connection times out before the PHP code can
produce any output.

Is there a way to log _all_ the SQL queries to a file?

Regards,

--
Gioele Barabucci <gioele.b...@uni-koeln.de>

Mike G

unread,
Jul 2, 2014, 1:56:39 PM7/2/14
to ica-ato...@googlegroups.com, gioele.b...@uni-koeln.de
Hi Gioele,

You can view all queries going through MySQL by using the General Query Log

The short version is log into MySQL as an administrative user (such as root), and use the following commands:

mysql> SET GLOBAL general_log = 1;
mysql> SHOW VARIABLES LIKE 'general_log_file';

The first line enables query logging. The second line will give you a file location where all queries going through MySQL will be logged. When you're finished running the queries you wanted to log, don't forget to turn off the general query log (as the file will get large after a while if you leave it on):

mysql> SET GLOBAL general_log = 0;

So say your general query log path in the second command above returned /var/lib/mysql/myhost.log, all the queries you issued should now be in that file.

Hope this helps.

Gioele Barabucci

unread,
Jul 3, 2014, 3:42:34 AM7/3/14
to Mike G, ica-ato...@googlegroups.com
Am 02.07.2014 19:56, schrieb Mike G:
> You can view all queries going through MySQL by using the General Query
> Log <http://dev.mysql.com/doc/refman/5.1/en/query-log.html>.
>
> The short version is log into MySQL as an administrative user (such as
> root), and use the following commands:
>
> *mysql> SET GLOBAL general_log = 1;*
> *mysql> SHOW VARIABLES LIKE 'general_log_file';*

Hi Mike,

I cannot enable the log on the MySQL server because the server is a
remote server (well, one meter away) that is used for many other
projects and has thousands of requests per second. I already asked the
DBAs to enable sql-server-side logs but they answered no.

This problem does not appear when using MySQL on localhost.

The only way I see to pinpoint this is to log on the web server every
query made by AtoM, but I do not see how to do that in the version of
Propel bundled with AtoM.

Bye,

--
Gioele Barabucci <gioele.b...@uni-koeln.de>

Dan Gillean

unread,
Jul 3, 2014, 12:52:25 PM7/3/14
to ica-ato...@googlegroups.com, Mike G
Hi Gioele,

I have recently added some documentation about logging in AtoM 2 here: https://www.accesstomemory.org/en/docs/2.0/admin-manual/maintenance/logging/#maintenance-logging

I hope that helps you get a bit more information.

Cheers,

Dan Gillean, MAS, MLIS
AtoM Product Manager / Systems Analyst,
Artefactual Systems, Inc.
604-527-2056
@accesstomemory




--
You received this message because you are subscribed to the Google Groups "ICA-AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-users+unsubscribe@googlegroups.com.
To post to this group, send email to ica-atom-users@googlegroups.com.
Visit this group at http://groups.google.com/group/ica-atom-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/53B50966.6090403%40uni-koeln.de.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages