Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Logs with web.WARNING when devMode is disabled #11141

Closed
martinleveille opened this issue May 7, 2022 · 6 comments · Fixed by #11216
Closed

[4.x]: Logs with web.WARNING when devMode is disabled #11141

martinleveille opened this issue May 7, 2022 · 6 comments · Fixed by #11216
Assignees

Comments

@martinleveille
Copy link

What happened?

With devMode enabled, you normally get these lines for each page load in the log files:

2022-05-07 14:01:11 [web.INFO] [yii\db\Connection::open] Opening DB connection: mysql:host=127.0.0.1;dbname=craft40;port=3306 {"memory":1604768}                                                                  
2022-05-07 14:01:11 [web.INFO] [yii\web\Session::open] Session started {"memory":2396792}                                                                                                                         
2022-05-07 14:01:11 [web.INFO] [application] Request context:

But when you disable devMode, you get a single web.WARNING line for each page load:

2022-05-07 14:06:21 [web.WARNING] [application] Request context:

Should this line be a web.INFO when devMode is disabled ?

Craft CMS version

4.0.1

PHP version

8.0.18

Operating system and version

Darwin 21.4.0

Database type and version

MySQL 8.0.28

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-30)

Installed plugins and versions

No plugins

@mattgrayisok
Copy link

As this context message is being logged for every request (and it's also a WARN so it's being logged twice for CRAFT_STREAM_LOG=1 due to #11189) it's creating a lot of log noise for high traffic sites.

I imagine it just needs removing altogether when devMode is false.

@timkelty
Copy link
Contributor

@martinleveille @mattgrayisok to clarify:

With devMode disabled, you should only get the request context logged when there is something else logged. Normally, in production, unless something is wrong, you shouldn't get any logs (I realize plugins, etc. can disrupt this).

It is logged as a warning, here, as it will be logged as your minimum configured log level. By default, with devMode off, that is warning.

If you'd rather disable the request context entirely (or conditionally), you can do so via monologTargetConfig.logContext, as shown here. We're actively working on official docs for this :)

@martinleveille
Copy link
Author

@timkelty Thanks for your answer and gist examples, but I've just done a clean install and only get [web.WARNING] [application] Request context: lines without anything else when devMode is disabled.

craft4_warning_logs.mp4

@timkelty
Copy link
Contributor

Thanks for the video @martinleveille. You're absolutely right. I did some further debugging with @mattgrayisok and am able to reproduce.

We'll have a fix out asap!

@timkelty
Copy link
Contributor

@martinleveille @mattgrayisok I have this fixed here

If you could try dev-fix-log-filtering and confirm it it fixed for you, that would be appreciated!

@brandonkelly
Copy link
Member

Craft 4.0.3 is out now with that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants