I want to catch all the errors and notify myself by email about them. redefined errorHandler

'errorHandler' => [ 'errorAction' => 'site/error', ] 

and 404 errors, but not fatal ones, pass through site / error. How to make it so that I could intercept all errors, including db exception, etc. Thank.

    1 answer 1

    You need to configure the mailer component and add a new Target to the Logger configuration:

     'components' => [ 'log' => [ 'targets' => [ [ 'class' => 'yii\log\EmailTarget', 'mailer' => 'mailer', 'levels' => ['error', 'warning'], 'message' => [ 'from' => ['log@example.com'], 'to' => ['developer1@example.com', 'developer2@example.com'], 'subject' => 'Log message', ], ], ], ], ], 

    Read about logging , everything is described in detail.