I have yii2-queue working – easy setup, works nicely.
For debug and monitoring purposes, I’d like to be able to see the debug output from jobs I submit to the queue. However, I’m struggling mightily with this.
Here is my current log setup in console/config/main.php (below). My goal is to break out logging into separate areas based on what I need to look at – a common need. I’m able to create the different log files just via using this configuration. However, what I can’t seem to get working is seeing Yii:debug() output when I submit a job to yii2-queue. In queue.log, I do see the queue runner grabbing the job. But I never see the Yii::debug() output I have in my job code. I have scanned all the log files and none of them have it, including debug.log, which has no category restrictions.
I’m clearly missing something. Help is appreciated.
'targets' => [
[
'class' => 'pahanini\log\ConsoleTarget',
'enabled' => true,
'levels' => ['error', 'warning', 'trace'],
'exportInterval' => 1,
'logVars' => [],
],
[
'class' => 'yii\log\FileTarget',
'enabled' => true,
'categories' => [ 'application' ],
'levels' => [ 'error', 'warning', 'trace' ],
'enableRotation' => true,
'logFile' => '@runtime/logs/app.log',
'logVars' => [],
],
[
'class' => 'yii\log\FileTarget',
'enabled' => true,
// https://forum.yiiframework.com/t/logger-doesnt-save-yii-info-messages-in-jobs-queue/131377
'categories' => [ 'api', 'cron', 'yii\queue\Queue', 'queue', 'collection', 'firewall' ],
'levels' => [ 'error', 'warning', 'trace', 'info' ],
'enableRotation' => true,
'logFile' => '@runtime/logs/queue.log',
'logVars' => [],
],
[
'class' => 'yii\log\FileTarget',
'enabled' => true,
//'categories' => [ 'application' ],
'levels' => [ 'error', 'warning' ],
'enableRotation' => true,
'logFile' => '@runtime/logs/error.log',
'logVars' => [],
],
[
'class' => 'yii\log\FileTarget',
'enabled' => true,
//'categories' => [ 'queue' ],
'levels' => [ 'error', 'warning', 'trace' ],
'enableRotation' => true,
'logFile' => '@runtime/logs/debug.log',
'logVars' => [],
],
],