# .NET Error Monitoring & Performance Monitoring

> Full stack traces, tracing, profiling, and logs for ASP.NET Core, MAUI, Blazor, and Entity Framework. Free to start.

**URL:** https://sentry.io/for/dot-net/

---

Actionable insights to solve .NET errors.

**Documentation:** [https://docs.sentry.io/platforms/dotnet/](https://docs.sentry.io/platforms/dotnet/)

## Install

### C#

Install the **NuGet** package to add the Sentry dependency:

```bash
dotnet add package Sentry
```

Initialize the SDK as early as possible, like in the `Main` method in `Program.cs/Program.fs`:

```csharp
using (SentrySdk.Init(o => {
  // Tells which project in Sentry to send events to:
  o.Dsn = "https://<key>@sentry.io/<project>";
  // When configuring for the first time, to see what the SDK is doing:
  o.Debug = true;
  // Set TracesSampleRate to 1.0 to capture 100% of transactions for Tracing.
  // We recommend adjusting this value in production.
  o.TracesSampleRate = 1.0; }))
{
  // App code goes here - Disposing will flush events out
}
```

See the [C# docs](https://docs.sentry.io/platforms/dotnet/) for full setup options.

### ASP.NET

Add the Sentry dependency:

```text
Install-Package Sentry.AspNet
```

You configure the SDK in the `Global.asax.cs`:

```csharp
using System;
using System.Web;
using Sentry;
using Sentry.AspNet;
using Sentry.EntityFramework; // if you also installed Sentry.EntityFramework
using Sentry.Extensibility;

public class MvcApplication : HttpApplication
{
    private IDisposable _sentry;

    protected void Application_Start()
    {
        // Initialize Sentry to capture AppDomain unhandled exceptions and more.
        _sentry = SentrySdk.Init(o =>
        {
            o.AddAspNet();
            o.Dsn = "https://<key>@sentry.io/<project>";
            // When configuring for the first time, to see what the SDK is doing:
            o.Debug = true;
            // Set TracesSampleRate to 1.0 to capture 100%
            // of transactions for performance monitoring.
            // We recommend adjusting this value in production
            o.TracesSampleRate = 1.0;
            // if you also installed the Sentry.EntityFramework package
            o.AddEntityFramework();
        });
    }

    protected void Application_Error()
    {
        var exception = Server.GetLastError();
        SentrySdk.CaptureException(exception);
    }

    protected void Application_BeginRequest()
    {
        Context.StartSentryTransaction();
    }

    protected void Application_EndRequest()
    {
        Context.FinishSentryTransaction();
    }

    protected void Application_End()
    {
        // Flushes out events before shutting down.
        _sentry?.Dispose();
    }
}
```

See the [ASP.NET docs](https://docs.sentry.io/platforms/dotnet/guides/aspnet/) for full setup options.

### ASP.NET Core

Add the Sentry dependency:

```bash
dotnet add package Sentry.AspNetCore
```

Configure Sentry in `appsettings.json`:

```json
"Sentry": {
  "Dsn": "https://examplePublicKey@o0.ingest.sentry.io/0",
  "Debug": true,
},
```

Then add the SDK by simply calling `UseSentry`:

```csharp
public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            // Add the following line:
            webBuilder.UseSentry();
        });
```

See the [ASP.NET Core docs](https://docs.sentry.io/platforms/dotnet/guides/aspnetcore/) for full setup options.

### .NET MAUI

Add the Sentry MAUI dependency:

```bash
dotnet add package Sentry.Maui
```

You configure the SDK in the `MauiProgram.cs`:

```csharp
public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()

        // Add this section anywhere on the builder:
        .UseSentry(options =>
        {
            // The DSN is the only required setting.
            options.Dsn = "https://<key>@sentry.io/<project>";

            // Other Sentry options can be set here.
        })

        // ... the remainder of your MAUI app setup

    return builder.Build();
}
```

See the [.NET MAUI docs](https://docs.sentry.io/platforms/dotnet/guides/maui/) for full setup options.

## Features

### .NET Error Monitoring with Complete Stack Traces

See .NET stack trace details like filename and line number so you never have to guess. Filter and group .NET exceptions intuitively to eliminate noise. Monitor errors at scale without impacting throughput in production.

### Performance Monitoring Across Services

Quickly identify .NET performance issues before they become downtime with [Tracing](/product/tracing/). View the entire end-to-end distributed trace to see the exact, poor-performing API call and surface any related errors.

### Fill In The Blanks

Expose the important events that led to each .NET exception: debug logs, network requests, database queries, past errors.

### See the Full Picture of Any Exception

With Sentry's exceptional exception handling in .NET, you can triage quickly based on specific parameters like HTTP request, workflow stage, and hostname for each issue. Set custom tags to recreate the error environment relevant to your app, business concerns, and users.

### Your Logs, Next to the Trace

Route Serilog, NLog, log4net, or Microsoft.Extensions.Logging output into Sentry and query it beside your [traces](/product/tracing/) and exceptions. The logging you already have becomes searchable context on the request that failed.

Learn more about [Logs in Sentry](/product/logs/).

## FAQ

**What is the difference between Sentry and traditional logging?**

Traditional logging provides you with a trail of events. Some of those events are errors, but many times they're simply informational. Sentry is fundamentally different because we focus on exceptions, or in other words, we capture application crashes. We discuss in more detail [here](/vs/logging/) and on our [blog](https://blog.sentry.io/lets-get-ready-to-monitor/).

**How do I connect issues to git commits?**

When Spring Boot is configured to generate Git information every event triggered by Sentry will have a release field set to the current Git commit ID that will enable Monitor Release Health Sentry feature. More details [here](https://docs.sentry.io/platforms/java/guides/spring-boot/#using-git-commit-id-as-the-release).

**How much does Sentry cost?**

You can get started for free. Pricing depends on the number of monthly events, transactions, and attachments that you send Sentry. For more details, visit our [pricing page](/pricing/).

**Which .NET frameworks does Sentry support?**

The Sentry .NET SDK covers [ASP.NET Core](/for/aspnetcore/) and [ASP.NET](/for/aspnet/), [MAUI](/for/dotnet-maui/), Blazor (both Interactive SSR and WebAssembly), Entity Framework, WPF, Windows Forms, WinUI and Xamarin, and runs on Windows, macOS, Linux, Android and iOS.

It integrates with Serilog, NLog, log4net and Microsoft.Extensions.Logging, and supports AWS Lambda, Azure Functions and Google Cloud Functions for serverless workloads.

**Can I send logs to Sentry?**

Yes. Sentry Logs lets you send, view, and query structured logs from your application alongside your errors and traces. Because logs sit next to the error and the trace that produced them, you get the granular context — retries, API failures, internal state — that spans and stack traces alone can miss, without switching tools.

Learn more about [Logs in Sentry](/product/logs/).

**What is Seer, Sentry's AI debugging agent?**

Seer is Sentry's AI debugging agent. It reads the full context Sentry already has — the error, its stack trace, the surrounding trace, logs, and profiles — to find the root cause of an issue and propose a fix. Seer can open a pull request with that fix, hand the work to an external coding agent, or review your PRs before they ship.

Learn more about [Seer](/product/seer/) and [Autofix](/product/seer/autofix/).

---

*Source: [sentry.io/for/dot-net/](https://sentry.io/for/dot-net/)*
