Yii2: remove Session console logs info

Created on 19 Dec 2019  路  8Comments  路  Source: yiisoft/yii2

What steps will reproduce the problem?

Start a session on code, so it happens almost to any request on the site.

What is the expected result?

Session started without any logs on the console.

What do you get instead?

I get a log similar to:
2019-12-19 11:33:58 [10.0.1.48][6456][-][info][yii\web\Session::open] Session started

It's quite painful because we have the server logs full of useless information. There's no need to log this by default. It seems it also logs the cookie information, so the log has even more information not needed.

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.13
| PHP version | 7
| Operating system | Ubuntu

The logging is in the line 140 of the file framework/web/Session.php. There should be a way to disable this logging or maybe it can be removed completely.

under discussion

Most helpful comment

We can lower log level to trace for it.

All 8 comments

Do you need info level logs on production?

We could move our logging to another level, but for now this is the only case where the framework is logging information that doesn't bring valuable data. All other logging we see it's useful.

We can lower log level to trace for it.

Going to trace level makes more sense to me than having info

@yiisoft/core-developers, @yiisoft/reviewers thoughts?

Opening a Session is a relevant information, especially with GDPR, where you might want to create sites again, which do not need a session/cookie by default.

If you do not want to log it, why don't you just add it to exclude of your logger?

Right. It can be added to exclude, indeed.

You are right, it seems I didn't check the documentation properly.
I've tried it and it works, I can exclude the Session start it in the config file.

BTW, is except and not exclude, just in case someones checks it later.
https://www.yiiframework.com/doc/api/2.0/yii-log-target#$except-detail

Was this page helpful?
0 / 5 - 0 ratings