---
title: "Quartz.NET"
description: "Learn how to monitor your Quartz.NET jobs."
url: https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz/
---

# Quartz.NET for MAUI

The `Sentry.Quartz` and `Sentry.Quartz3` packages monitor your [Quartz.NET](https://www.quartz-scheduler.net/) jobs by [creating check-ins for them](https://docs.sentry.io/product/monitors-and-alerts/monitors/crons/job-monitoring.md). They're available from SDK version 6.13.0. Use `Sentry.Quartz` with Quartz.NET 4.x and `Sentry.Quartz3` with Quartz.NET 3.x (3.6 and later).

## [Install](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#install)

```shell
dotnet add package Sentry.Quartz
```

*Other available variations of the above snippet: Package Manager*

For Quartz.NET 3.x, install `Sentry.Quartz3` instead. With Quartz.NET 4.x, `Sentry.Quartz3` sends no check-ins and logs an error in [debug mode](https://docs.sentry.io/platforms/dotnet/guides/maui/configuration/options.md#debug).

## [Configure](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#configure)

Initialize Sentry as usual, then add Sentry to your scheduler.

### [Quartz.NET 4.x](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#quartznet-4x)

Call `AddSentry` when you configure Quartz.NET:

```csharp
using Quartz;
using Sentry.Quartz;

builder.Services.AddQuartz(q =>
{
    q.AddSentry();
});
```

Each job then runs in its own Sentry scope and trace, tagged with `quartz.job`, and the SDK captures the exceptions jobs throw in that scope.

### [Quartz.NET 3.x](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#quartznet-3x)

Add `SentryJobListener` to your scheduler. If you register Quartz.NET with dependency injection, `AddQuartz` comes from the `Quartz.Extensions.DependencyInjection` package, or from `Quartz.Extensions.Hosting` if you also run the scheduler as a hosted service:

```csharp
using Quartz;
using Sentry.Quartz;

builder.Services.AddQuartz(q =>
{
    q.AddJobListener<SentryJobListener>();
});
```

Or add the listener to a scheduler directly:

```csharp
scheduler.ListenerManager.AddJobListener(new SentryJobListener());
```

## [Choose Which Jobs to Monitor](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#choose-which-jobs-to-monitor)

For each monitored job, the SDK captures a check-in with `CheckInStatus.InProgress` when the job starts. When the job finishes, it updates the check-in to `CheckInStatus.Ok`, or to `CheckInStatus.Error` if the job threw an exception or was cancelled, along with how long the job ran.

With Quartz.NET 4.x, the SDK captures each exception a job throws once, in the job's scope, so it's tagged with `quartz.job` and shares a trace with the check-in.

With Quartz.NET 3.x, the SDK doesn't capture the exceptions jobs throw. A failed run still sends an error check-in, but Quartz.NET handles the exception itself and logs it as an error. That log entry only reaches Sentry if you use one of Sentry's hosting integrations, such as `Sentry.Extensions.Hosting` or `Sentry.AspNetCore`, or one of its logging integrations, such as `Sentry.Extensions.Logging`. These events aren't tagged with `quartz.job` and don't share a trace with the check-in.

### [Monitor All Jobs](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-all-jobs)

We recommend monitoring every scheduled job. Set `MonitorAllJobs`, and jobs whose trigger has a schedule Sentry can send are monitored without adding an attribute to each class. Jobs aren't monitored when the trigger that started them has a schedule Sentry can't send (see [Monitor Schedule](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-schedule)), or when they're built without `WithIdentity`. Jobs whose triggers have different schedules, or that share a slug with a job on a different schedule, aren't monitored either, since Sentry can't create one monitor for them.

To skip some jobs, add them to `ExcludedJobs`. A string matches a job whose name or full key (`group.name`) is equal to it, and a `Regex` matches a job whose name or full key it matches. Jobs with `[SentryMonitorSlug]` are monitored even when they match.

```csharp
q.AddSentry(options =>
{
    options.MonitorAllJobs = true;
    options.ExcludedJobs.Add("reports.AdhocExport");
    options.ExcludedJobs.Add(new Regex(@"^maintenance\."));
});
```

*Other available variations of the above snippet: Quartz.NET 3.x*

These jobs use the slug of their job key, described below.

### [Monitor Specific Jobs](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-specific-jobs)

To monitor only some jobs, add the `SentryMonitorSlug` attribute to each job class you want to monitor. Jobs without it aren't monitored unless `MonitorAllJobs` is set.

```csharp
[SentryMonitorSlug]
public class PricingUpdateJob : IJob
{
    // ...
}
```

With `MonitorAllJobs` on, a job with the attribute still sends one check-in per run, using the attribute's slug and settings.

## [Monitor Slugs](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-slugs)

To choose the slug, pass it to the attribute:

```csharp
[SentryMonitorSlug("update-pricing")]
public class PricingUpdateJob : IJob
```

Without one, the slug is the job's group and name joined by `-`, or only the name for jobs in the default group, normalized the same way Sentry normalizes monitor slugs: lowercased, accents removed, spaces and dashes replaced by a single `-`, other characters dropped, and cut to 50 characters. For example, the job `billing.PricingUpdate` reports to `billing-pricingupdate`, `reports.Daily_Email (v2)` reports to `reports-daily_email-v2`, and the job `Cleanup` in the default group reports to `cleanup`. A job whose key leaves nothing is not monitored unless you set a slug.

A job built without `WithIdentity` gets a new random name each time it's created, so the SDK uses the name of the job's class instead, such as `pricingupdatejob`. Give the job an identity or a slug to keep its monitor the same. If triggers that share a slug have different schedules, the SDK doesn't send a schedule for them.

To use a different slug for one job or trigger, set `SentryMonitorSlugAttribute.JobDataKey` in its data map:

```csharp
var job = JobBuilder.Create<PricingUpdateJob>()
    .WithIdentity("PricingUpdate", "billing")
    .UsingJobData(SentryMonitorSlugAttribute.JobDataKey, "update-pricing")
    .Build();
```

## [Monitor Schedule](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-schedule)

Sentry only creates a monitor from a check-in that includes a schedule. For monitored jobs, the SDK sends the schedule of the trigger that started the job:

* Cron triggers, with the trigger's time zone. Quartz.NET cron triggers use the server's local time zone unless you set one with `InTimeZone`, so set it if your servers don't all use the same time zone. The cron expression must use a fixed number of seconds and no year, `L`, `W`, or `#`. Quartz.NET 3.x needs `?` in exactly one of the two day fields. Quartz.NET 4.x also accepts `*` or values in both. When both have values, the job runs on days that match either field, and Sentry reads the schedule the same way.
* Simple triggers that repeat forever every whole number of minutes, hours, or days.

Other triggers, triggers with a calendar, and time zones without an IANA ID (Windows time zone IDs on .NET Framework) are sent without a schedule. So are triggers that share a slug but have different schedules, for example two triggers of the same job. To give each trigger its own monitor, set a different slug in each trigger's data map.

Sentry can't create a monitor from a check-in without a schedule, so `MonitorAllJobs` skips these jobs. To monitor one anyway, add `[SentryMonitorSlug]` to it, and either create its monitor in Sentry or set its schedule with [`ConfigureMonitorOptions`](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-settings).

Sentry sets the monitor's schedule and time zone from every check-in that includes them, so changes you make to those two settings in Sentry are overwritten. Other monitor settings are kept. To stop sending the schedule for one job, set `SendMonitorConfig` on its attribute:

```csharp
[SentryMonitorSlug(SendMonitorConfig = false)]
public class PricingUpdateJob : IJob
```

To stop sending it for all jobs, set `SendMonitorConfig` in the options:

```csharp
q.AddSentry(options => options.SendMonitorConfig = false);
```

*Other available variations of the above snippet: Quartz.NET 3.x*

If you delete a monitor while its job is still monitored, the next run that sends a schedule creates it again. To stop monitoring a job, disable the monitor in Sentry, remove the attribute, or add the job to `ExcludedJobs`.

## [Monitor Settings](https://docs.sentry.io/platforms/dotnet/guides/maui/crons/quartz.md#monitor-settings)

To set other monitor settings, such as the thresholds or the maximum runtime, use `ConfigureMonitorOptions`. It runs before each in-progress check-in with the job's `IJobExecutionContext`, unless `SendMonitorConfig` is off. A schedule or time zone you set here is used instead of the trigger's. Sentry only receives these settings along with a schedule, from the trigger or set here, so you can also use it to set the schedule of a trigger the SDK can't send:

```csharp
q.AddSentry(options => options.ConfigureMonitorOptions = (context, monitorOptions) =>
{
    monitorOptions.MaxRuntime = TimeSpan.FromMinutes(30);
    monitorOptions.FailureIssueThreshold = 3;
});
```

With Quartz.NET 3.x, set it on the `SentryQuartzOptions` you pass to `SentryJobListener`.
