You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serilog Sinks error and performance monitoring with Raygun is available using the serilog-sinks-raygun provider.
serilog-sinks-raygun is a library that you can easily add to your website or web application, which will then monitor your application and display all Serilog errors and issues affecting your users within your Raygun account. Installation is painless.
The provider is a single package (Serilog.Sinks.Raygun) which includes the sole dependency (Serilog), allowing you to drop it straight in.
Getting started
Step 1 - Add packages
Install the Serilog (if not included already) and Serilog.Sinks.Raygun package into your project. You can either use the below dotnet CLI command, or the NuGet management GUI in the IDE you use.
The following examples are for .NET 6.0+ applications. For other frameworks, please refer to the .NET Framework Readme.
Example of setup for ASP.NET Applications:
usingMindscape.Raygun4Net.AspNetCore;usingSerilog;varbuilder=WebApplication.CreateBuilder(args);// Add Raygunbuilder.Services.AddRaygun(builder.Configuration);builder.Services.AddRaygunUserProvider();builder.Host.UseSerilog((context,provider,config)=>{// Add the Raygun sinkconfig.WriteTo.Raygun(raygunClient:provider.GetRequiredService<RaygunClient>());});
Example of setup for Console/Service:
usingMindscape.Raygun4Net;usingSerilog;usingSerilog.Sinks.Raygun.Extensions;varhost=Host.CreateDefaultBuilder(args).ConfigureServices((context,services)=>{// Add Raygunservices.AddRaygun(context.Configuration);services.AddHostedService<Worker>();}).UseSerilog((_,serviceProvider,config)=>{// Add the Raygun sinkconfig.WriteTo.Raygun(raygunClient:serviceProvider.GetRequiredService<RaygunClient>());}).Build();awaithost.RunAsync();
Example of setup for MAUI:
usingSerilog;varbuilder=MauiApp.CreateBuilder();builder.UseMauiApp<App>()// Add Raygun.AddRaygun();varapp=builder.Build();Log.Logger=newLoggerConfiguration().MinimumLevel.Debug()// Add the Raygun sink.WriteTo.Raygun(raygunClient:app.Services.GetRequiredService<RaygunMauiClient>()).CreateLogger();returnapp;
Configuration Properties
raygunClient
type: RaygunClientBase
required
This property is required for the Raygun Sink to function. The client can be any implementation that inherits from RaygunClientBase, this could be the Raygun4Maui client, Raygun4Net.AspNetCore client, or Raygun4Net.NetCore client. Ideally, this is resolved from the ServiceCollection in .NET Core applications.
formatProvider
type: IFormatProvider
default: null
This property supplies culture-specific formatting information. By default, it is null.
restrictedToMinimumLevel
type: LogEventLevel
default: LogEventLevel.Error
You can set the minimum log event level required in order to write an event to the sink. By default, this is set to Error as Raygun is mostly used for error reporting.
Enrich with HTTP request and response data
Properties included from other Serilog Enrichers should automatically be included into the Raygun errors.
To use the old Raygun Enricher you can follow the Enricher Readme to add the enricher to your project.