Skip to content

Add additional LoggerMessageAttribute constructors #87254

@noahfalk

Description

@noahfalk

By @geeknoid

  • Event id is not an effective concept; customers don't want to use it and don't have anything to do with it. So, we want overloads that don't require that.
  • We are trying to shift customers to not use message strings and stick with structured logging. So, we want overloads that don't include a message.
  • We routinely find situations where log levels are specified as a logging method parameter rather than in the attribute definition, so we want overloads that don't include a level.

Bottom line is that the lack of these constructors leads to considerably more ceremony for the customers. More stuff to type with no upside to them.

Proposal

public sealed class LoggerMessageAttribute : Attribute
{
    public LoggerMessageAttribute()
    public LoggerMessageAttribute(int eventId, LogLevel level, string message)

+   public LoggerMessageAttribute(LogLevel level, string message)
+   public LoggerMessageAttribute(LogLevel level)
+   public LoggerMessageAttribute(string message)
}

Original description

dotnet/extensions supports a variety of shortcut constructors on LogMethodAttribute. In the past these shortcuts were deemed undesirable. While I don't know the details behind the original decisions, now that we have more history of internal usage and a better track record we should reconsider.

@geeknoid - can you enumerate exactly which APIs you hope to bring over?

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-Extensions-Loggingpartner-impactThis issue impacts a partner who needs to be kept updated

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions