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

LoggerMessage - Allow Event ID to be optional #52223

Closed
maryamariyan opened this issue May 3, 2021 · 2 comments
Closed

LoggerMessage - Allow Event ID to be optional #52223

maryamariyan opened this issue May 3, 2021 · 2 comments

Comments

@maryamariyan
Copy link
Member

maryamariyan commented May 3, 2021

Using LoggerMessage attribute today required each logging method to have a unique event ID in a given class.
Otherwise, we get a warning SYSLIB1006, stating we should not be reusing event IDs.

This issue tracks allowing uses of the LoggerMessage attribute without defining an event ID, but, adding a Roslyn Analyzer that warns/errors to recommend best practices.

This is more useful for library developers than it is for app developers which most times might want to cut corners and skip providing event IDs.

Originally requested in dotnet/designs#195 (comment).

cc: @loic-sharma @shirhatti


UPDATE

How to address:

When event ID is not set, it will default to -1, when multiple logging methods in a class don't have event ID set, they all default to -1, causing the SYSLIB1006 warning.

@maryamariyan maryamariyan added this to the 6.0.0 milestone May 3, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label May 3, 2021
@ghost
Copy link

ghost commented May 3, 2021

Tagging subscribers to this area: @maryamariyan
See info in area-owners.md if you want to be subscribed.

Issue Details

Using LoggerMessage attribute today required each logging method to have a unique event ID in a given class.
Otherwise, we get a warning SYSLIB1006, stating we should not be reusing event IDs.

This issue tracks allowing uses of the LoggerMessage attribute without defining an event ID, but, adding a Roslyn Analyzer that warns/errors to recommend best practices.

This is more useful for library developers than it is for app developers which most times might want to cut corners and skip providing event IDs.

Originally requested in dotnet/designs#195 (comment).

cc: @loic-sharma

Author: maryamariyan
Assignees: -
Labels:

area-Extensions-Logging

Milestone: 6.0.0

@maryamariyan
Copy link
Member Author

Closed via #54305

@ghost ghost locked as resolved and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant