Yii2 Logger - Custom Categories - Global Variables

Hi everybody,

I’ve customized “config/web.php” in Yii2 basic template such that:




        'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [

            	[

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

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

            	],

	            [

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

            		'levels' => ['info'],

            		'categories' => ['abc'],

            		'except' => ['application'],

            		'logFile' => '@app/runtime/logs/abc/abc.log',

            		'maxFileSize' => 1024 * 2,

            		'maxLogFiles' => 20,

            	],

            ],

        ],



abc.log is created successfully by:




Yii::info('Abc...', 'abc');



However, in the log, it reads:




2014-09-16 12:28:36 [127.0.0.1][][-][info][abc] Abc...

2014-09-16 12:28:36 [127.0.0.1][][-][info][application] $_COOKIE = [

    '_csrf' => 'ad2cb9811237ac355861d97c989c8120fe51501a8279cade52b27c95e4e3de48s:32:\"qoQUT3Fnftck_Ygsb3XHLPn_vQhi0Yoy\";'

    'PHPSESSID' => '7vu7oieb0vk2mfts6rjsa3o5j6'

]


$_SESSION = [

    (....too many data....)

]


$_SERVER = [

    (....too many data....)

]




What I want in the log file is just:




2014-09-16 12:28:36 [127.0.0.1][][-][info][abc] Abc...



So, how can I remove/disable these global variables? Or how to customize the way I log?

I finally solved my problem:




        'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [

                [

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

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

                ],

                [

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

                        'levels' => ['info'],

                        'categories' => ['abc'],

                        'logVars' => [null],

                        'logFile' => '@app/runtime/logs/abc/abc.log',

                        'maxFileSize' => 1024 * 2,

                        'maxLogFiles' => 20,

                ],

            ],

        ],



logVars is the key: ‘logVars’ => [null],

http://www.yiiframework.com/doc-2.0/yii-log-target.html#$logVars-detail