Reputation: 52932
I've installed the package "ElmahCore" which allowed me to use Elmah in .NET Core. It's set up by:
services.AddElmah();
in the startup.cs
I want to change it to log to SQL so it's persistent. However it's unclear how - there is no web.config, it appears to be no-configuration. There aren't any options I can see either to add SQL logging.
There's an elmah.corelibrary nuget package
, but it doesn't seem to play with the first library - doing services.AddElmah<SqlErrorLog>
which has been suggested elsewehre doesn't work because it's the wrong ErrorLog
class.
Alternatively if there's a better framework for .net core that will log exceptions with persistence and allow sending notification e-mails it would be appreciated, I am wondering if Elmah is past its sell by date.
Upvotes: 3
Views: 5330
Reputation: 5239
The elmah.corelibrary
package is part of ELMAH for ASP.NET (not core). To log to SQL Server from ASP.NET Core, you need to install the ElmahCore.Sql
NuGet package to get the correct SqlErrorLog
class:
using ElmahCore.Mvc;
using ElmahCore.Sql;
...
services.AddElmah<SqlErrorLog>(options =>
{
options.ConnectionString = "Server=localhost;Database=ELMAH;Integrated Security=True;";
});
As for your questions for ELMAH in general, it is definitely not dead. ELMAH for ASP.NET is sort of complete while work on different log "appenders" still happen. ElmahCore is a port from the original ELMAH code to support ASP.NET Core. I'm the founder of elmah.io which offer you to store error messages in the cloud (as well as a range of other features which makes the name confusing I know). There are similar solutions out there like Raygun and Stackify.
Upvotes: 7