Andreas Hinderberger
Andreas Hinderberger

Reputation: 1525

Yii2 disable debug log for specific controller/action

In general in development mode i have to use the debug and logging for bugtracing.

But on a specific controller/action i don't want this to happen since it's just a background ajax that gets called every 2 seconds, which ends ups in a huge amount of "unneeded" logs.

How can I exclude this specific call "site/ajaxupdate" from being logged?

Upvotes: 2

Views: 3727

Answers (2)

rockfade
rockfade

Reputation: 9

YII 2 it may be accomplished by:

foreach (\Yii::$app->log->targets as $target) {
    $target->setEnabled(false);
}

Upvotes: 1

soju
soju

Reputation: 25312

You could simply disable the corresponding log target in your controller, e.g. :

\Yii::$app->log->targets['file']->enabled = false;

Read more about toggling log targets.

Upvotes: 4

Related Questions