You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The remarks for theMicrosoft.Extensions.Logging.LoggerMessageAttribute specify that the partial method MUST have a LogLevel parameter. This is not true, if it is provided in the attribute constructor already. And even if it isn't, the source generator still generates a valid method body, and it defaults to the None level.
The Learn Feedback Control issue template used when clicking the Open documentation issue link on the doc seems broken, at least on Edge 150 on Windows 11. It is impossible to edit the text in the comment box (just gets reset to the placeholder text no matter what you do). And then it got auto-closed for that reason. And then the bot said feel free to re-open, but I don't have permission to do so. So, here's a new issue. ↩
Thanks for reporting this. You're right about the main point: the log level doesn't have to be a method parameter, it can be set on the attribute (via a constructor argument or the Level property), so the old remark saying it must be a parameter was wrong. #130320 fixes the wording.
And thanks for the clarification on point 2. I could have sworn I saw it do it, but I must have been looking at the attribute itself or something and mixed that up with the generated code in my head on the way from VS to the docs to here. 😅
Activity
gewarren commentedon Jul 7, 2026
Thanks @dodexahedron , I opened dotnet/dotnet-api-docs#12866 to fix the template issue.
dotnet-policy-service commentedon Jul 7, 2026
Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.
tarekgh commentedon Jul 7, 2026
Thanks for reporting this. You're right about the main point: the log level doesn't have to be a method parameter, it can be set on the attribute (via a constructor argument or the
Levelproperty), so the old remark saying it must be a parameter was wrong. #130320 fixes the wording.One correction on the second part though: a log level is still required, it just has to be provided in one of those two places. If you omit it from the attribute and don't have a
LogLevelparameter, the source generator reportsSYSLIB1017(MissingLogLevel) and doesn't generate the method, so it doesn't silently default toNone. You can see that in the generator here: https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs#L516So the corrected remark reads: the method must specify a log level, either on the attribute or as a
LogLevelparameter.dodexahedron commentedon Jul 7, 2026
Cool. Sounds ideal.
And thanks for the clarification on point 2. I could have sworn I saw it do it, but I must have been looking at the attribute itself or something and mixed that up with the generated code in my head on the way from VS to the docs to here. 😅
Also, confirmed that dotnet/dotnet-api-docs#12866 does appear to have made filling out that template possible again. 👍 Thanks @gewarren
Fix inaccurate LogLevel constraint in LoggerMessageAttribute remarks (#…
Fix inaccurate LogLevel constraint in LoggerMessageAttribute remarks (#…