From 2a31f598a7ce05fbb6b7121166d7c8a4b18d447d Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 7 Jul 2024 22:49:09 +0200 Subject: [PATCH] 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. --- .../Elsa.Mediator/HostedServices/JobRunnerHostedService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/Elsa.Mediator/HostedServices/JobRunnerHostedService.cs b/src/common/Elsa.Mediator/HostedServices/JobRunnerHostedService.cs index d271df18e..223eb35f4 100644 --- a/src/common/Elsa.Mediator/HostedServices/JobRunnerHostedService.cs +++ b/src/common/Elsa.Mediator/HostedServices/JobRunnerHostedService.cs @@ -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);