Add error logging to JobRunnerHostedService

Previously, only job cancellations were logged. Now, in addition to logging job cancellations, the service will also log errors when a job fails, providing better diagnostics and troubleshooting.
This commit is contained in:
Sipke Schoorstra 2024-07-07 22:49:09 +02:00
parent 1c9f6648e4
commit 2a31f598a7

View file

@ -44,6 +44,10 @@ public class JobRunnerHostedService : BackgroundService
{
_logger.LogInformation("Job {JobId} was canceled", jobItem.JobId);
}
catch (Exception ex)
{
_logger.LogError(ex, "Job {JobId} failed", jobItem.JobId);
}
finally
{
jobItem.OnJobCompleted(jobItem.JobId);