Skip to content

LoggerMessage - Allow Event ID to be optional #52223

@maryamariyan

Description

@maryamariyan

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions