frops
frops

Reputation: 2365

How to remove unnecessary logging in Yii2?

I set up a separate logging for their own purposes

'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['info'],
                'categories' => [
                    'mycat',
                ],
                'logFile' => '@app/runtime/logs/mycat.log'
            ]
        ],
    ],

Then, a specific event is logged

Yii::info("It's work", 'mycat');

After that, I expect that in the file mycat.log will only "It's work", but this is still being written log category of "application":

tail -f runtime/logs/mycat.log

enter image description here

Question: How to disable log for application in mycat.log?

P.S. Sorry, for my english. Sorry, sorry :(

Upvotes: 3

Views: 4306

Answers (1)

soju
soju

Reputation: 25312

You should simply disable variables logging, e.g. :

[
    'class' => 'yii\log\FileTarget',
    'levels' => ['info'],
    'categories' => ['mycat'],
    'logVars' => [],
    'logFile' => '@app/runtime/logs/mycat.log'
]

Read more about $logVars.

Upvotes: 8

Related Questions