Question : The current default implementation of CriticalBackgroundService.OnError log to the console. Is this a design choice ?
I'm using your library in one of my windows service application (from a worker service) and a few days ago it crashed. In my log file, I only had "INFO ... Microsoft.Hosting.Lifetime - Application is shutting down...". No reason why. From the lines before the shutdown, I could guess that it crashed during an operation inside the CriticalBackgroundService and no log/exception was written.
I found out that the CriticalBackgroundService.OnError will not log to an ILogger, but to the console. Obviously the console is not redirected to my log file. I'm using Microsoft ILogger, and my ILogger is configured to output to log4net, which log to a file and also the console.
I could think that you're using console because you're targetting a basic program, without any ilogger and all the DI stuff. However that can't be the case because you're already registering your services with the microsoft DI in the readme file and the HostedService you're trying to fix are from asp.net / worker.
I've implemented the virtual OnError in all my background service to log to my ILogger, so i'm fine with the rest and I don't require any modification from your part. I was kinda not expecting it to log to console, but instead to log to ILogger by default.
Is it by design that CriticalBackgroundService log to console, while PeriodicTaskRunnerBackgroundService use the ILogger facility ?
When I check the rest of your project, PeriodicTaskRunnerBackgroundService seems to use ILogger to report crash, but CriticalBackgroundService only use the console. Perhaps it's because it's critical ?