Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should i look for Yii2 log exception file

Tags:

php

yii2

A beginner to Yii 2 framework, can anyone please tell me where do i find the log exception file or if have to create the file to store all exceptions then how should i create one ?

like image 243
Rock Rathore Avatar asked Sep 03 '25 05:09

Rock Rathore


2 Answers

By default, Yii2 logs error and warning level events into the runtime/logs/app.log file. You can read more about configuring logging in Yii2 in e.g. the Definitive Guide.

like image 52
mcserep Avatar answered Sep 04 '25 19:09

mcserep


If you're are using the Advanced Application Template, each app (frontend, backend) has his own runtime/logs folder with a log file.

Also, you can add in config file this setting, for components, to receive and email every time a level of error you've set, occurs:

'log' => [
            'targets' => [
                'email' => [
                    'class' => 'yii\log\EmailTarget',
                    'levels' => ['error'],
                    'message' => [
                        'from' => 'app-email', 
                        'to' => 'your-email',
                        'subject' => 'Log message',
                    ],
                ],
            ],
        ],

Very useful for production.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!