Open
Description
Background and motivation
Currently, it seems that using resource strings with the logging source generator is not possible. I suggest adding the ResourceName
and ResourceType
properties to the [LoggerMessageAttribute]
, similar to the ErrorMessageResourceName
and ErrorMessageResourceType
properties used in the ValidationAttribute
.
API Proposal
public LoggerMessageAttribute (int eventId, Microsoft.Extensions.Logging.LogLevel level, Type resourceType, string resourceName);
API Usage
Given LoggingResource.resx
resource strings file and UnexpectedError
name, the new API could be used like this:
public static class LoggingExtensions
{
[LoggerMessage(LogLevel.Error, 0, typeof(LoggingResource), nameof(LoggingResource.UnexpectedError))]
public partial void UnexpectedError(this ILogger, Exception exception);
}
Alternative Designs
No response
Risks
No response