Logging EF Core

Learn about EF Core logging, enabling monitoring of interactions with the database, controlling sensitive data logging, and enhancing logging clarity.

Logging

We can enable logging to monitor the interaction between EF Core and the database. Logging could be to the console, Debug or Trace, or a file.

EF Core logging

By default, EF Core logging will exclude any data in case it is sensitive. We can include this data by calling the EnableSensitiveDataLogging method, especially during development. We should disable it again before deploying it to production.

Example

Let’s see an example of this in action:

Step 1: In Northwind.cs ...