MySQL - 如何跟踪每个查询?
可能重复:
如何启用 MySQL 查询日志?
有没有办法跟踪 MySQL 中的每个 SQL 查询?
我正在使用 Doctrine ORM 构建实体并从数据库中获取它们,并且想看看 Doctrine 产生了哪些查询.那么当我刷新一个使用 Doctrine ORM 从数据库中获取一些数据的网页时,我在哪里可以看到在数据库中执行的查询?
这可能吗?
解决方案让这个应用程序决定是否要记录查询,如果要记录所有查询,请在 MySQL 端记录查询.
Doctrine 在包中有一个内置的记录器接口和一个演示记录器.来自 http://docs.doctrine-project.org/en/2.0.x/reference/configuration.html#sql-logger-optional:
setSQLLogger($logger);$config->getSQLLogger();
<块引用>
获取或设置记录器,用于记录 Doctrine 执行的所有 SQL 语句.记录器类必须实现 DoctrineDBALLoggingSQLLogger 接口.可以在 DoctrineDBALLoggingEchoSQLLogger 中找到使用 echo 和 var_dump 记录到标准输出的简单默认实现.`
Possible Duplicate:
How to enable MySQL Query Log?
Is there a way to track every SQL query in MySQL?
Im using Doctrine ORM to build entities and fetch them from database, and would like to see what queries is Doctrine producing. So when I refresh a webpage that uses Doctrine ORM to fetch some data from database, where could I see queries executed in database?
Is this possible?
解决方案Let this application decide if you want queries logged and log queries on MySQLs side if you want all queries logged.
Doctrine has a builtin logger interface and a demo logger in the package. From http://docs.doctrine-project.org/en/2.0.x/reference/configuration.html#sql-logger-optional :
<?php
$config->setSQLLogger($logger);
$config->getSQLLogger();
Gets or sets the logger to use for logging all SQL statements executed by Doctrine. The logger class must implement the DoctrineDBALLoggingSQLLogger interface. A simple default implementation that logs to the standard output using echo and var_dump can be found at DoctrineDBALLoggingEchoSQLLogger.`
相关文章