Logging from Entity Framework Core
Both elmah.io and Entity Framework Core supports logging through Microsoft.Extensions.Logging. To log all errors happening inside Entity Framework Core, install the Elmah.Io.Extensions.Logging NuGet package:
Then add elmah.io to a new or existing
var loggerFactory = new LoggerFactory() .AddElmahIo("API_KEY", new Guid("LOG_ID"));
Finally, enable logging in Entity Framework Core:
optionsBuilder .UseLoggerFactory(loggerFactory) .UseSqlServer(...);
UseSqlServer included for illustration purposes only - elmah.io works with any provider)
That's it! All errors happening in Entity Framework Core, are now logged in elmah.io.
This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening and help you fix errors fast.