We have an ASP.NET Core app that uses recurring jobs to run in jobs in the background that, occasionally fail due to reasons that have nothing to do with Hangfire. I would like to control how these errors are logged globally and have read all Microsoft and Serilog writings I can find on logging. Most of the Microsoft advice pertains to logging middleware, meaning it does not speak to Hangfire jobs that run in the background. Is there any Hangfire specific hook I can use to handle what gets logged when errors occur in a background job? Barring a global hook, how can I catch and log an exception and then tell Hangfire the job failed without logging another exception?
We are trying to control what gets logged and where, as errors that occur in the background currently leak too many implementation details to reports our users can view.