Answer the question
In order to leave comments, you need to log in
How to enable console command logging in Yii2?
I am developing a controller that will be launched by cron. Accordingly, the controller is console and information about requests to this controller is not logged in Yii Debugger.
In console.php config:
'bootstrap' => ['log', 'gii','debug'],
'controllerNamespace' => 'app\commands',
'modules' => [
'gii' => 'yii\gii\Module',
'debug' => [
'class' => 'yii\debug\Module',
'allowedIPs' => ['*'],
],
],
Answer the question
In order to leave comments, you need to log in
Because for me, logging console controllers was necessary to determine what data to load through ->with, the solution turned out to be the following:
after executing a request to the database, I hang up a handler on the ActiveRecord::EVENT_AFTER_FIND event and look at the objects of which classes are taken from the database after the request is executed. This is how I determine which links are not yet specified in ->with
Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_FIND, function (Event $event) {
echo $event->sender->className()."\n";
});
As far as I remember, this is unfortunately not possible in console mode.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question