Perhaps, many are familiar with the ELMAH (Error Logging Modules and Handlers) library , which allows you to organize simple error logging for any site created with the .NET Framework.
This simple and time-tested tool has helped me out in many projects.
Several years ago, while creating my new project for .NET Core, I was annoyed to find that ELMAH does not work under .NET Core.
opensource ! , ELMAH .NET Core.
, , pet-. , , «» ElmahCore.
, ElmahCore – opensource , , .NET Core.
, , :
- ,
- HTTP : (header), , cookies,
, Microsoft.Extensions.Logging (ILogger) HTTP .
:
- XML
- , MSSQL, MySQL, PostgreSQL
:
- nuget- elmahcore.
- Startup.cs:
services.AddElmah(); // ConfigureServices app.UseElmah(); // Configure
.
, , ~/elmah.
UI, VUE.js
, . :
services.AddElmah(options => { options.SourcePaths = new [] { @"D:\tmp\ElmahCore.DemoCore3", @"D:\tmp\ElmahCore.Mvc", @"D:\tmp\ElmahCore" }; });
«Log» Microsoft.Extensions.Logging HTTP .
, !
, :
services.AddElmah(options => { options.OnPermissionCheck = context => context.User.Identity.IsAuthenticated; });
UseElmah, UseAuthentication UseAuthorization
app.UseAuthentication(); app.UseAuthorization(); app.UseElmah();
You can filter logged errors using filters implemented in code (implementing the IErrorFilter interface) or in the xml configuration file ( https://elmah.github.io/a/error-filtering/examples/ ).
services.AddElmah<XmlFileErrorLog>(options => { options.FiltersConfig = "elmah.xml"; options.Filters.Add(new MyFilter()); })
In addition to registering the error log, the library allows you to organize the distribution of notifications (via the IErrorNotifier implementation), for example, to e-mail.
services.AddElmah<XmlFileErrorLog>(options => { options.Notifiers.Add(new ErrorMailNotifier("Email",emailOptions)); });
Hope this free library is helpful in your projects.
More information about the library can be found here .