https://github.com/anfomin/rayguncore
Raygun provider for .NET Core and ASP.NET Core
https://github.com/anfomin/rayguncore
aspnet-core aspnetcore netcore raygun
Last synced: about 2 months ago
JSON representation
Raygun provider for .NET Core and ASP.NET Core
- Host: GitHub
- URL: https://github.com/anfomin/rayguncore
- Owner: anfomin
- License: mit
- Created: 2018-02-12T16:44:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-09T07:12:56.000Z (5 months ago)
- Last Synced: 2025-04-14T22:52:29.247Z (about 2 months ago)
- Topics: aspnet-core, aspnetcore, netcore, raygun
- Language: C#
- Size: 75.2 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Raygun provider for .NET
Standart [Raygun4Net library](https://github.com/MindscapeHQ/raygun4net) does not work well with .NET. So I've created library for new architecture:
- Built with interfaces and works via default dependency injection;
- As result, services can be easily extended or replaced;
- You can work via `IRaygunClient` directly or use `RaygunLogger` or intergrate handler into ASP.NET Core pipeline.## Installation via NuGet
Package | Description | NuGet
----------------------|-------------------------------------------|-------
RaygunCore | Raygun client and logger | [](https://www.nuget.org/packages/RaygunCore)
RaygunCore.AspNetCore | Handler for ASP.NET Core request pipeline | [](https://www.nuget.org/packages/RaygunCore.AspNetCore)## How to use with ASP.NET Core
Register services in `Startup` class:
```C#
public void ConfigureServices(IServiceCollection services)
{
// configure with API KEY
services.AddRaygun("_API_KEY_")
.WithHttp();// or with options
services.AddRaygun(opt => opt.ApiKey = "_API_KEY_")
.WithHttp();// or with configuration section
services.AddRaygun(configuration)
.WithHttp();
}
```Method `AddRaygun()` registers only minimal required services. So then you can request `IRaygunClient` service and send errors:
```C#
public async Task ActionInController([FromServices]IRaygunClient raygun)
{
try
{
// some code
}
catch (Exception ex)
{
await raygun.SendAsync(ex);
}
return "OK";
}
```Method `WithHttp()` in application services registration adds pipeline handler so any exception in request is automatically sent to Raygun.
## How to use with logging
You can register Raygun logger provider:
```C#
WebHost.CreateDefaultBuilder(args)
.UseStartup()
.ConfigureLogging((context, logging) => logging
.AddRaygun(r => r
.Configure(opt => opt.ApiKey = "_API_KEY_")
.WithHttp()
)
);
```Then just use logger:
```C#
public async Task ActionInController([FromServices]ILogger logger)
{
logger.LogError(0, "My error message");
}
```## License
This package has MIT license. Refer to the [LICENSE](LICENSE) for detailed information.