{"id":13445549,"url":"https://github.com/ElmahCore/ElmahCore","last_synced_at":"2025-03-20T21:30:56.673Z","repository":{"id":38361390,"uuid":"113406868","full_name":"ElmahCore/ElmahCore","owner":"ElmahCore","description":"ELMAH for Net.Standard and Net.Core ","archived":false,"fork":false,"pushed_at":"2024-04-03T01:33:09.000Z","size":13455,"stargazers_count":311,"open_issues_count":85,"forks_count":94,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-10-05T22:15:13.719Z","etag":null,"topics":["asp-net-core","asp-net-core-mvc","aspnetcore","aspnetcoremvc","elmah","elmah-core","error-handling","error-log","errors","logging","mvc","mvc-core","mvc6","net-core","net-core-3","net-core-5","net-core-6","netcore","netstandard","netstandard20"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ElmahCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-07T05:27:59.000Z","updated_at":"2024-10-05T11:32:53.000Z","dependencies_parsed_at":"2023-02-14T19:16:13.612Z","dependency_job_id":"e50fc1e4-cc9b-475a-b8eb-0392b8593c92","html_url":"https://github.com/ElmahCore/ElmahCore","commit_stats":{"total_commits":141,"total_committers":31,"mean_commits":4.548387096774194,"dds":0.5460992907801419,"last_synced_commit":"aa8a6734b406f654706811810b600255686f5523"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElmahCore%2FElmahCore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElmahCore%2FElmahCore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElmahCore%2FElmahCore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElmahCore%2FElmahCore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ElmahCore","download_url":"https://codeload.github.com/ElmahCore/ElmahCore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221807734,"owners_count":16883639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-core","asp-net-core-mvc","aspnetcore","aspnetcoremvc","elmah","elmah-core","error-handling","error-log","errors","logging","mvc","mvc-core","mvc6","net-core","net-core-3","net-core-5","net-core-6","netcore","netstandard","netstandard20"],"created_at":"2024-07-31T05:00:35.855Z","updated_at":"2025-03-20T21:30:56.660Z","avatar_url":"https://github.com/ElmahCore.png","language":"C#","readme":"This project is licensed under the terms of the Apache license 2.0.\n\n# Using ElmahCore\nELMAH for Net.Standard and Net.Core (3.1, 5, 6)\n\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-new-ui.png)\n\nAdd nuget package **elmahcore**\n\n## Simple usage\n Startup.cs\n```csharp\n1)\tservices.AddElmah() in ConfigureServices \n2)\tapp.UseElmah(); in Configure\n```\n`app.UseElmah()` must be after initializing other exception handling middleware, such as (UseExceptionHandler, UseDeveloperExceptionPage, etc.)\n\nDefault elmah path `~/elmah`.\n\n## Change URL path\n```csharp\nservices.AddElmah(options =\u003e options.Path = \"you_path_here\")\n```\n## Restrict access to the Elmah url\n```csharp\nservices.AddElmah(options =\u003e\n{\n        options.OnPermissionCheck = context =\u003e context.User.Identity.IsAuthenticated;\n});\n```\n**Note:** `app.UseElmah();` needs to be after \n```\napp.UseAuthentication();\napp.UseAuthorization();\napp.UseElmah();\n```\nor the user will be redirected to the sign in screen even if he is authenticated.\n## Change Error Log type\nYou can create your own error log, which will store errors anywhere.\n```csharp\n    class MyErrorLog: ErrorLog\n    //implement ErrorLog\n```\n This ErrorLogs available in board:\n - MemoryErrorLog – store errors in memory (by default)\n - XmlFileErrorLog – store errors in XML files\n - SqlErrorLog - store errors in MS SQL (add reference to [ElmahCore.Sql](https://www.nuget.org/packages/ElmahCore.Sql))\n - MysqlErrorLog - store errors in MySQL (add reference to [ElmahCore.MySql](https://www.nuget.org/packages/ElmahCore.MySql))\n - PgsqlErrorLog - store errors in PostgreSQL (add reference to [ElmahCore.Postgresql](https://www.nuget.org/packages/ElmahCore.Postgresql))\n```csharp\nservices.AddElmah\u003cXmlFileErrorLog\u003e(options =\u003e\n{\n    options.LogPath = \"~/log\"; // OR options.LogPath = \"с:\\errors\";\n});\n```\n```csharp\nservices.AddElmah\u003cSqlErrorLog\u003e(options =\u003e\n{\n    options.ConnectionString = \"connection_string\";\n    options.SqlServerDatabaseSchemaName = \"Errors\"; //Defaults to dbo if not set\n    options.SqlServerDatabaseTableName = \"ElmahError\"; //Defaults to ELMAH_Error if not set\n});\n```\n## Raise exception\n```csharp\npublic IActionResult Test()\n{\n    HttpContext.RaiseError(new InvalidOperationException(\"Test\"));\n    ...\n}\n```\n## Microsoft.Extensions.Logging support\nSince version 2.0 ElmahCore support Microsoft.Extensions.Logging\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-log.png)\n\n## Source Preview\nSince version 2.0.1 ElmahCore support source preview.\nJust add paths to source files.\n```csharp\nservices.AddElmah(options =\u003e\n{\n   options.SourcePaths = new []\n   {\n      @\"D:\\tmp\\ElmahCore.DemoCore3\",\n      @\"D:\\tmp\\ElmahCore.Mvc\",\n      @\"D:\\tmp\\ElmahCore\"\n   };\n});\n```\n\n## Log the request body\nSince version 2.0.5 ElmahCore can log the request body.\n\n## Logging SQL request body\nSince version 2.0.6 ElmahCore can log the SQL request body.\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-4.png)\n\n## Logging method parameters\nSince version 2.0.6 ElmahCore can log method parameters.\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-5.png)\n```csharp\nusing ElmahCore;\n...\n\npublic void TestMethod(string p1, int p2)\n{\n    // Logging method parameters\n    this.LogParams((nameof(p1), p1), (nameof(p2), p2));\n    ...\n}\n\n```\n\n## Using UseElmahExceptionPage\nYou can replace UseDeveloperExceptionPage to UseElmahExceptionPage\n```csharp\nif (env.IsDevelopment())\n{\n   //app.UseDeveloperExceptionPage();\n   app.UseElmahExceptionPage();\n}\n```\n\n## Using Notifiers\nYou can create your own notifiers by implement IErrorNotifier or IErrorNotifierWithId interface and add notifier to Elmah options:\n```csharp\nservices.AddElmah\u003cXmlFileErrorLog\u003e(options =\u003e\n{\n    options.Path = @\"errors\";\n    options.LogPath = \"~/logs\";\n    options.Notifiers.Add(new ErrorMailNotifier(\"Email\",emailOptions));\n});\n```\nEach notifier must have unique name.\n## Using Filters\nYou can use Elmah XML filter configuration in separate file, create and add custom filters:\n```csharp\nservices.AddElmah\u003cXmlFileErrorLog\u003e(options =\u003e\n{\n    options.FiltersConfig = \"elmah.xml\";\n    options.Filters.Add(new MyFilter());\n})\n```\nCustom filter must implement IErrorFilter.\nXML filter config example:\n```csharp\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" ?\u003e\n\u003celmah\u003e\n\t\u003cerrorFilter\u003e\n\t\t\u003cnotifiers\u003e\n\t\t\t\u003cnotifier name=\"Email\"/\u003e\n\t\t\u003c/notifiers\u003e\n\t\t\u003ctest\u003e\n\t\t\t\u003cand\u003e\n\t\t\t\t\u003cgreater binding=\"HttpStatusCode\" value=\"399\" type=\"Int32\" /\u003e\n\t\t\t\t\u003clesser  binding=\"HttpStatusCode\" value=\"500\" type=\"Int32\" /\u003e\n\t\t\t\u003c/and\u003e \n\t\t\u003c/test\u003e\n\t\u003c/errorFilter\u003e\n\u003c/elmah\u003e\n```\nsee more [here](https://elmah.github.io/a/error-filtering/examples/)\n\nJavaScript filters not yet impemented :(\n\nAdd notifiers to errorFilter node if you do not want to send notifications\nFiltered errors will be logged, but will not be sent.\n\n## Search And Filters\n\nSince version 2.2.0 tou can use full-text search and multiple filter.\n\nFull-text search work on analyzed text fields.\n\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-filters-1.png)\n\nFilters are available through either the **Add filter** button.\n\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-filters-2.png)\n\nOr you can use **filter icon** to the right of the error field.\n\n![alt text](https://github.com/ElmahCore/ElmahCore/raw/master/images/elmah-filters-3.png)\n\nCurrently supports only Memory and XmlFile error logs.","funding_links":[],"categories":["Frameworks, Libraries and Tools","框架, 库和工具"],"sub_categories":["Logging","日志"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FElmahCore%2FElmahCore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FElmahCore%2FElmahCore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FElmahCore%2FElmahCore/lists"}