Answer the question
In order to leave comments, you need to log in
Yii2 - how not to log an exception?
Good afternoon. There was a following problem:
From the user the request comes. Inside the action, an external API is called, and if the necessary information is not received from the API, it is necessary to throw a NotFoundHttpException to the user. But I don't want to see this exception in the logs.
I see the following solution:
Yii::$app->log->targets['file']->enabled = false;
throw new NotFoundHttpException...
Answer the question
In order to leave comments, you need to log in
Yes, this solution, provided the correct route is specified, should solve the problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question