Skip to content

Commit

Permalink
feat: add sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
Azaferany committed Jul 26, 2022
1 parent ef3529b commit 90ab194
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/QuickstartTemplate.WebApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using QuickstartTemplate.WebApi;
using Sentry;
using Serilog;
using Serilog.Events;

var builder = WebApplication.CreateBuilder(args);

// Manually create an instance of the Startup class
// https://andrewlock.net/exploring-dotnet-6-part-12-upgrading-a-dotnet-5-startup-based-app-to-dotnet-6/
var startup = new Startup(builder.Configuration);
builder.WebHost.UseSentry((builderContext, sentryOptions) =>
{
sentryOptions.Dsn = builderContext.Configuration["SENTRY_DSN"];
sentryOptions.AddExceptionFilterForType<OperationCanceledException>();
});

builder.Host.UseSerilog((context, configuration) =>
{
Expand All @@ -18,9 +21,16 @@

configuration.MinimumLevel.Is(logEventLevel);

configuration.Enrich.FromLogContext().WriteTo.Console();
configuration.Enrich.FromLogContext();

configuration.WriteTo.Console();
configuration.WriteTo.Sentry();
});

// Manually create an instance of the Startup class
// https://andrewlock.net/exploring-dotnet-6-part-12-upgrading-a-dotnet-5-startup-based-app-to-dotnet-6/
var startup = new Startup(builder.Configuration);

// Manually call ConfigureServices()
startup.ConfigureServices(builder.Services);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.20.0" />
<PackageReference Include="Sentry.Serilog" Version="3.20.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
Expand Down

0 comments on commit 90ab194

Please sign in to comment.