[SERVER-49745] Subtle undocumented difference between LOGV2 and LOGV2_INFO. Created: 20/Jul/20  Updated: 06/Jan/23  Resolved: 19/Apr/21

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Backlog - Security Team
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-49750 Document logv2 in Security Architectu... Backlog
Related
is related to SERVER-72583 Make the mongo shell have the same de... Backlog
Assigned Teams:
Server Security
Sprint: Security 2020-09-21
Participants:

 Description   

There's a subtlety that is disorienting, between LogSeverity::Log and LogSeverity::Info, because they appear identical in the log output, but they respond to verbosity filters as distinct severity levels.  the `Log` severity is 0, and the `Info` severity is -1. These severities, though distinct internally, will both appear as an "s":"I" in the log output.

As a result, it's unclear to users when to use LOGV2_INFO and when to use the default LOGV2. Guidance and documentation on this severity folding behavior would helpful.

=== Slack transcript (or approximation thereof) ===

Billy Donahue Today at 2:23 PM
no, you're off by one there . The default is LogSeverity::Log, which is LogSeverity(0). LOGV2_INFO goes to LogSeverity::Info, which is LogSeverity(-1). (edited)
14 replies

louis.williams 31 minutes ago
What is the difference in the log output?

louis.williams 31 minutes ago
Also, there isn’t any guidance when to use one or the other.

The severity appears in the "s" key of the json output object.
And I think you are right about the missing guidance. I looked around a bit and didn't find any.

Just testing locally, the “s” field is “I” for both LOGV2 and LOGV2_INFO

https://github.com/mongodb/mongo/blob/master/src/mongo/logv2/log_severity.cpp#L69 <=where the magic happens.

I think it's definitely worth a ticket. That line in log_severity.cpp is very subtle and needs user-facing documentation.
I think they're affected by verbosity filtering differently, even though they appear indistinguishable in the log.



 Comments   
Comment by Gabriel Russell (Inactive) [ 31/Jul/20 ]

FYI, this is not a difference new to logv2. This behavior is just carried over from the legacy logger.

Comment by Billy Donahue [ 20/Jul/20 ]

louis.williams FYI

Generated at Thu Feb 08 05:20:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.