logger for module


I have Yii2 Advance template, in which I have managed One module for “webservices”, Yii2 give default logs on runtime directory. in this logs, I have only logs related to the main app not for the module. So I changed my config/main.php’s component with

'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [


                    'class' => 'yii\log\FileTarget',

                    'levels' => ['error', 'warning','info'],

                    'categories' => ['frontend\modules\*'],

                    'logFile' => '@frontend/logs/frontend.modules.info.log',




Let me know what wrong I did and if this method is entirely wrong how to achieve that in yii2

That’s fine. The idea is to specify category (be it a class name or just a string) and then filter by it in the log config. I guess you’ve missed 1st part of it and haven’t specified category while logging.