This page links to Logging in ASP.NET Core but there are no instructions on how to configure EF Core logging there.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@paulomorgado the first paragraph in this page is the shortest answer:
EF Core integrates automatically with the logging mechanisms of ASP.NET Core whenever AddDbContext or AddDbContextPool is used.
That means that we automatically wire up things so that the DbContext will use the ILoggerFactory dependency of the application. For example, if you create an ASP.NET Core application with ASP.NET Core Identity, the code that you get from the templates already configures EF Core to use the logging configured in ASP.NET Core. Let us know if there is anything specific we could add to make this clearer.
If you're creating the DbContext manually, just make sure to call UseApplicationServiceProvider on the options builder, so that it uses the same services as the rest of the application.
Most helpful comment
If you're creating the
DbContextmanually, just make sure to callUseApplicationServiceProvideron the options builder, so that it uses the same services as the rest of the application.