Yii2: How to register exceptions?

What happens if I register an exception? Example:

Yii::error(new Exception('test'));

Currently, nothing happens to my base application template. Nothing is logged (further calls to error () are not logged). It's right? Configuration:

'log'          => [
  'traceLevel' => YII_DEBUG ? 3 : 0,
  'targets'    => [
    [
      'class'  => 'yii\log\FileTarget',
      'levels' => ['error', 'warning'],
    ],
  ],
],

I expected exceptions to be logged accordingly. How do I log exceptions, especially. if i want to see the trace?

Update:

See Issue on GitHub. With Yii 2.0.6, exceptions can be logged.

, . . , , Yii, ( ?) $previous. , .

+4
1

, .

Yii::error(). :

1) :

throw new \Exception("My error message #1");

2) Yii::error()

Yii::error("My error message #2");

, , .

+4

All Articles