dotnet-core-sdk-beta icon indicating copy to clipboard operation
dotnet-core-sdk-beta copied to clipboard

Exception with RunEnvironment : Method not found with loggerfactory

Open nagasivaram-tadepalli opened this issue 4 years ago • 3 comments

Hi I got this exception while running a sample with ASP.Net Core 3.1

: Method not found: 'Microsoft.Extensions.Logging.ILoggerFactory Microsoft.Extensions.Logging.DebugLoggerFactoryExtensions.AddDebug(Microsoft.Extensions.Logging.ILoggerFactory, Microsoft.Extensions.Logging.LogLevel)'.

nagasivaram-tadepalli avatar Jun 04 '20 06:06 nagasivaram-tadepalli

Also having this issue using .Net Core 3.1

LCotts avatar Jul 06 '20 14:07 LCotts

Same here. The issue, I think, is because ApiOperationBase has static Logger instance of type Microsoft.Extensions.Logging.ILogger, that is invoked in the ApiOperationBase constructor. But in case of .Net Core xx there's no way to pass ILogger reference (service?) to it...

qfilip avatar Jul 29 '20 08:07 qfilip

Just for other people, I have compiled the code for Core 3.1. The change required is in the LogFactory.cs GetLog method : return new LoggerFactory().CreateLogger(classType.FullName);

That have seems to do the trick. No more error and things seem to work as before. Hope this helps someone.

totalpanic avatar Mar 03 '21 22:03 totalpanic