Entityframework.docs: ASP.NET Core logging

Created on 7 Oct 2018  Â·  2Comments  Â·  Source: dotnet/EntityFramework.Docs

This page links to Logging in ASP.NET Core but there are no instructions on how to configure EF Core logging there.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Most helpful comment

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.

All 2 comments

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

norvegec picture norvegec  Â·  3Comments

MohammadMQ picture MohammadMQ  Â·  3Comments

CeciAc picture CeciAc  Â·  4Comments

speciesunknown picture speciesunknown  Â·  3Comments

Praveen-Rai picture Praveen-Rai  Â·  4Comments