AnderssonPeter / Hangfire.Console.Extensions

Makes it easier to use Hangfire.Console with .net core dependency injection
MIT License
78 stars 17 forks source link

LogLevel.None not supported #16

Closed AlexisPicot closed 7 months ago

AlexisPicot commented 7 months ago

Logging work as expected on other portions of the code Trying to add Dataverse SDK and provide logger to the constructor using classical provider.GetRequiredService<ILogger<IOrganizationService>> This library tries to log something with LogLevel.None, not sure if it is useless or not but whatever

I'm encoutering issue while logging :

An error occurred while writing to logger(s). (Specified argument was out of the range of valid values. (Parameter 'logLevel'))

Microsoft.PowerPlatform.Dataverse.Client.Utils.DataverseConnectionException: An error occurred while writing to logger(s). (Specified argument was out of the range of valid values. (Parameter 'logLevel'))
 ---> System.AggregateException: An error occurred while writing to logger(s). (Specified argument was out of the range of valid values. (Parameter 'logLevel'))
 ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'logLevel')
   at Hangfire.Console.Extensions.HangfireLogger.GetLogLevelString(LogLevel logLevel)
   at Hangfire.Console.Extensions.HangfireLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|13_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state)

I think the problem lies here : https://github.com/AnderssonPeter/Hangfire.Console.Extensions/blob/4e99c1563a440e08098ef3550444cee461d59d4d/Hangfire.Console.Extensions/HangfireLogger.cs#L20-L23

Whereas https://github.com/AnderssonPeter/Hangfire.Console.Extensions/blob/4e99c1563a440e08098ef3550444cee461d59d4d/Hangfire.Console.Extensions/HangfireLogger.cs#L46-L66

Argument may be thrown if LogLevel.None is supplied

AnderssonPeter commented 7 months ago

If you have the time to provide a PR I will merge it, but I can't say when I will create a new nuget