Immediately write logs in long running console command

I’ve some long running background runners and I want to know their current state. I added several Yii::info statements through the code, but (at least in this testing time) Yii isn’t writing them until the command completes. Moreover, if I forcefully stop commands with ^C, log messages are lost.

At the beginning of the action I added

Yii::$app->log->flushInterval = 1;

but doesn’t change anything.

Logger configuration:

        'class' => 'yii\log\DbTarget',
        'levels' => ['error', 'warning', 'info'],
        'logTable' => '{{%mylog}}',
        'categories' => ['hlmw*'],

Try also setting 'exportInterval' => 1, for your log target.