I'm wondering how to add console logging to EF.Core without getting an "obsolete" warning.
Given:
DbContextOptionsBuilder<BenchmarkDbContext> builder = ...;
I tried:
builder.UseLoggerFactory(new LoggerFactory().AddConsole())
And tried:
var factory = new LoggerFactory();
factory.AddProvider(new ConsoleLoggerProvider((a, b) => true, true));
builder.UseLoggerFactory(factory)
I think the initialization of logger is changed in EFCore 3.x. Try using this:
public static readonly ILoggerFactory factory
= LoggerFactory.Create(builder => { builder.AddConsole(); });
See details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With