Problem/Motivation
Currently a number of user activities log messages at a "notice" level that are more correctly categorized as "info" messages, per RFC 5424, namely:
* User Registration notices
* User Login notices
* User Role additions / updates
* User Password Recovery Requests
* User using "one time" login link
* User sessions start / end
* User accounts blocked / deleted
* User Flood control notices
In all of the above instances, when these messages are logged the system is actually functioning as designed, and logging these events is truly "informational" in nature.
Proposed resolution
Let's lower the log message Severity level to one more appropriate, and log these as info events, not notices.
User interface changes
The user login and related messages are now styles as "info" messages rather than "notice" messages.
Before

After

Release notes snippet
Log level changes
Some routine user events which were previously logged as notices are now logged at the lower-severity "info" level. A change record lists which user events are now logged at the "info" level.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | after patch.png | 254.32 KB | ameymudras |
| #37 | before patch.png | 232.51 KB | ameymudras |
| #36 | 3193759-36.patch | 8.13 KB | bhanu951 |
| #24 | interdiff_3193759_21-24.txt | 517 bytes | _pratik_ |
| #24 | 3193759-24.patch | 7.4 KB | _pratik_ |
Issue fork drupal-3193759
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3193759-demote-user-log
changes, plain diff MR !3165
Comments
Comment #2
lisa.rae commentedComment #3
lisa.rae commentedComment #4
zviryatko commentedComment #5
anmolgoyal74 commentedThere are two more cases which I think should also be changed to info.
In
core/modules/user/src/Form/UserPasswordForm.php,submitForm()Comment #6
baliram.patil commentedUpdated patch according to #5
Comment #7
longwaveI think most of the changes such as password resets, sessions and one time logins are OK, except for:
I would suggest that flood controls are "normal but significant" and should remain as notices. These do not occur very often in normal operation.
Perhaps also login failures are "normal but significant"?
Deleting a user is certainly a "significant" event. Should blocking be considered the same?
Comment #8
lisa.rae commentedIt's a philosophical discussion on whether certain event messages qualify as "notices" or "informational" messages. I could argue that "Flood control" and "Blocked user" could be considered "notices", I think a failed login is definitely an "informational" message. My thought on categorizing these messages in the User module as informational is as follows:
In looking through message logs, "notice" is the level that is also applied to PHP messages that, in and of themselves do not halt code processing, but usually indicate that the code is badly written (missing variable, missing array key /value, etc). Notices related to proper code processing, such as Flood Control events or Failed Logins, are not indicative of coding issues but are instead system events where the system is operating as expected, but the log message indicates an event worth noting.
As such, I would argue that PHP notices are more significant events that require developer attention, and should be prioritized higher than a failed login or a flood control event.
The real issue here is that we are using message level logging for different events, not all that require developer attention.
IMO, messages that are indicative of properly executing code, but indicate events that are worth noting should be logged as informational. This would include Flood Control, Failed Logins, and Blocked users.
Comment #9
vikashsoni commentedBy this patch #6 we can Demote user log entries from "notice" to "info".
Comment #12
mrconnerton commentedRerolled for 9.3.x / 9.4.x. Resolved conflicts.
Comment #13
mfbPSR-3 says notice is "Normal but significant events" and info is "Interesting events. Example: User logs in, SQL logs."
So it seems clear that user login should be logged as "info" :) Meanwhile the events that longwave flagged in #7 do seem more like "normal but significant".
The concept of "notice" is definitely tricky, partly because RFC 5424 and PHP errors use completely different sets of levels, and software has to figure out how to map between the two.. I think of PHP notices as being more error-like than RFC 5424 notices..
Comment #14
zviryatko commented@mfb I guess the main reason for such clean up (at least in my case) is that code (php) issues are not equal to application logic issues, so maybe users should see code issues as separate dashboard? Or at least we should provide documentation for that. I.e., for external log systems, it should send only php issues. I think both types of issues are important, but for different roles. Application logic issues for creating content, blocked users, or possibly some failed orders are critical. For example, if order failed, it is a critical issue for business, but not the same as "undefined is not a function"-like one. Worst scenario if there is connection to external api, and if api respond with 500 issue, because of something failed, i.e. your transaction failed in a middle, or if it returns 5xx response but with validation error - user's credit card doesn't have enough funds. Main question for me – should we collect both errors together? If yes, then ->notice("flood: User blocked") and ->notice("php: Undefined index") are the same level. But in other case better to split them.
Comment #15
mfb@zviryatko Yes it's a good idea to assign errors to the right team and alert them, whether through configuring Monolog or configuring an external log system.. Probably lots more community documentation on this is needed :)
This is a good reminder that a change record will be needed, as folks may already have setup custom logging logic, so adding a tag for that.
Comment #16
mfbCreated a draft change record: https://www.drupal.org/node/3259469
It's currently out of sync with the most recent patch on this issue. In light of @longwave's review at #7 I'd suggest rolling a new patch with slightly fewer changes, so that there can be consensus to get something committed :)
Comment #19
mfbThis needs another reroll and also needs some of the demotions removed as per #7
Comment #20
_pratik_Comment #21
_pratik_Rerolled patch for 10.1.x with #7 demotions.
Please check
thanks
Comment #22
_pratik_Comment #23
_pratik_Comment #24
_pratik_Fixed CCF indentation.
Comment #25
longwave#24 works for me, all the messages that have been demoted are informational only.
Comment #26
xjmThis seems sensible. The CR is succinct but sufficient as well. I made a small edit to the CR to make the before/after clearer.
I think we should consider this for the release notes also. My reasoning is that folks could have automated tooling that audits these logs, including security-incident-related stuff, and such tooling might just silently stop reporting rather than triggering an error condition that a site owner would investigate and follow to the CR. So marking NW for the release note. Thanks!
Comment #27
xjmSaving issue credits for the original issue report, necessary rerolls, and helpful reviews and discussions that make it clear this fix is the right choice.
Comment #28
mfbAdded release notes; fixed typo in change record
Comment #29
xjmThansk @mfb.
The patch no longer applies, so will need a reroll.
Comment #30
nitin shrivastava commentedreroll for 10.1.x
Comment #31
xjm@Nitin shrivastava Thank you for your attempts to reroll this patch.
Unfortunately, the reroll is incorrect. If you compare the diffstats using either Dreditor or git on the command line, you can see that the two patches have a different number of lines changed. The first has:
7 files changed, 10 insertions, 10 deletions.The second has:
7 files changed, 9 insertions, 9 deletions.If you look at
RoleFormwith your rerolled patch applied, you can see where there is still another instance that needs to be changed:When you reroll patches, please ensure all of the changes from the previous patch are included. You can use the
git diff --statcommand for an overview of the changes, and you should read both the original patch and your reroll.Review the instructions on rerolling patches for a full list of steps to take for the reroll and things to check. If you need assistance with a reroll, you can also get assistance in Drupal Slack.
Thanks!
Comment #32
xjmTagging for reroll again and hiding the incorrect patch.
Comment #35
bhanu951 commentedRe Rolled for 10.1.x Based on patch from #24.
Comment #36
bhanu951 commentedRe Rolled to patch as GITLAB is having hiccups with MR.
Comment #37
ameymudras commentedTested #36 on Drupal 10.1.x
- The issue summary makes sense and provides the necessary details
- The patch applies cleanly
- The severity changes from notice to info
- Release notes have been provided
- Did a code review and there are no noticeable issues
Marking this issue as RTBC
Comment #39
xjmThanks @Bhanu951 for your reroll and @ameymudras for your review. I did not think to look at the change in markup as a result of the patch, so that's helpful. In the future, you can embed your screenshot images in the issue summary "User interface changes" section to make the issue easier to review. I've done that now.
I also edited the release note so that the link text will be unique and meaningful out of context. (This is an accessibility requirement.)
Comment #41
xjmWith the patch applied, I reviewed which User module events are still notices:
For these:
core/modules/user/user.installand the next line is:That's important information, because it affects the user's access to the site and may indicate a data integrity issue.
Finally, I reviewed the change with
git diff --color-wordsand confirmed that the only changes are the method "notice" being changed to "info" in the 10 relevant places.Committed to 10.1.x, and published the change record. Also tagging for the release notes in case we decide to include it there. Thanks everyone!
Comment #42
mfbLooks like we've made a little rabbit hole of log level demotion issues; maybe we can look at #3255699: Demote routine content entity log entries from "notice" to "info" next.
Comment #44
xjmThis was already added to the 10.1.0 release notes draft. We should ensure that related issues update the same CR.