启用查询记录后日志文件位于何处? [英] Where is the log file after enabling query logging?
本文介绍了启用查询记录后日志文件位于何处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我按照说明在cakephp v3中启用查询记录功能。
I followed the instructions to enable query logging in cakephp v3.
http://book.cakephp.org/3.0/en/orm/database-basics.html#query-logging
// Turn query logging on.
$conn->logQueries(true);
// Turn query logging off
$conn->logQueries(false);
use Cake\Log\Log;
// Console logging
Log::config('queries', [
'className' => 'Console',
'stream' => 'php://stderr',
'scopes' => ['queriesLog']
]);
// File logging
Log::config('queries', [
'className' => 'File',
'path' => LOGS,
'file' => 'queries.log',
'scopes' => ['queriesLog']
]);
启用查询记录后,我无法找到日志文件。我在日志文件夹下查看。我没有看到任何 queries.log
。在哪里可以找到日志文件?
After enabling query logging, I am not able to find the log file. I looked under the logs folder. I don't see any queries.log
. Where can the log file be found?
推荐答案
我创建了一个测试项目。创建一个简单的模型,以便我可以解析数据。
I've created a test project. Created a simple model so I can parse the data.
在控制器中,我添加了这些命名空间:
In the controller, I added these namespaces:
use App\Model\Table\User; // <---My model
use Cake\ORM\TableRegistry;
use Cake\Log\Log;
use Cake\Datasource\ConnectionManager;
以下是控制器中的基本数据解析:
Here's the basic data parse in a controller:
$conn = ConnectionManager::get('default');
Log::config('queries', [
'className' => 'File',
'path' => LOGS,
'file' => 'queries.log',
'scopes' => ['queriesLog']
]);
$users = TableRegistry::get('User');
$conn->logQueries(true);
$q = $users->find('all');
$results = $q->all();
$conn->logQueries(false);
所有这些都很棒。
这篇关于启用查询记录后日志文件位于何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文