N
N
nepster-web2014-07-15 17:32:40
Yii
nepster-web, 2014-07-15 17:32:40

How to get rid of $_SERVER in Yii2 logs?

Log settings

'log' => [
            'traceLevel' => 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['info'],
                    'categories' => ['binary'],
                    'logFile' => '@console/runtime/binary/credits_exchange_success.log',
                ],
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error'],
                    'categories' => ['binary'],
                    'logFile' => '@console/runtime/binary/credits_exchange_error.log',
                ],
            ],
        ],

Making a log entry
Yii::getLogger()->log('error message', Logger::LEVEL_ERROR, 'binary');

Everything works, everything is fine, except that the listing of the $_SERVER array constantly gets into the log files, please tell me how to get rid of this entry?
And 1 more question is that the logs folder is created, where is the app.log file , which duplicates the error logs. Can you get rid of it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Osher, 2014-07-15
@nepster-web

Everything is easily customizable.
https://github.com/yiisoft/yii2/blob/master/framew...

I
IIISpikerIII, 2014-12-25
@IIISpikerIII

...  
[
   'class' => 'yii\log\FileTarget',
   'levels' => ['info'],
   'categories' => ['binary'],
   'logVars' => ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION'],
   'logFile' => '@console/runtime/binary/credits_exchange_success.log',
],
...

A
alexmgf, 2015-03-15
@alexmgf

Spiker hinted correctly, rewriting FileTarget for this is stupid... correct the config by adding
'logVars' => []

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question