Make sure AkkaHostedService failures are always visible#494
Conversation
close akkadotnet#470 - application crashes and exits should always be explicitly logged someplace where they can be seen regardless of logging configuration.
| Logger.Log(LogLevel.Critical, ex, "Unable to start AkkaHostedService - shutting down application"); | ||
|
|
||
| // resolve https://github.com/akkadotnet/Akka.Hosting/issues/470 - never allow failures to be silent | ||
| Console.WriteLine($"Unable to start AkkaHostedService due to [{ex}] - shutting down application"); |
There was a problem hiding this comment.
Ensure that this gets logged regardless of how the MSFT.EXT.Logger inputs have been configured
There was a problem hiding this comment.
I think for exception, it should always be added at the end, because the stack trace will screw up the string formatting.
There was a problem hiding this comment.
Or we can change that to "due to [{ex.Message}] - shutting down application.\nCause: {ex}"
There was a problem hiding this comment.
or maybe we should just re-throw the exception as a new exception and let MS.EXT.Hosting deal with it.
Arkatufus
left a comment
There was a problem hiding this comment.
I think this should be changed a bit
| Logger.Log(LogLevel.Critical, ex, "Unable to start AkkaHostedService - shutting down application"); | ||
|
|
||
| // resolve https://github.com/akkadotnet/Akka.Hosting/issues/470 - never allow failures to be silent | ||
| Console.WriteLine($"Unable to start AkkaHostedService due to [{ex}] - shutting down application"); |
There was a problem hiding this comment.
I think for exception, it should always be added at the end, because the stack trace will screw up the string formatting.
| Logger.Log(LogLevel.Critical, ex, "Unable to start AkkaHostedService - shutting down application"); | ||
|
|
||
| // resolve https://github.com/akkadotnet/Akka.Hosting/issues/470 - never allow failures to be silent | ||
| Console.WriteLine($"Unable to start AkkaHostedService due to [{ex}] - shutting down application"); |
There was a problem hiding this comment.
Or we can change that to "due to [{ex.Message}] - shutting down application.\nCause: {ex}"
| Logger.Log(LogLevel.Critical, ex, "Unable to start AkkaHostedService - shutting down application"); | ||
|
|
||
| // resolve https://github.com/akkadotnet/Akka.Hosting/issues/470 - never allow failures to be silent | ||
| Console.WriteLine($"Unable to start AkkaHostedService due to [{ex}] - shutting down application"); |
There was a problem hiding this comment.
or maybe we should just re-throw the exception as a new exception and let MS.EXT.Hosting deal with it.
Aaronontheweb
left a comment
There was a problem hiding this comment.
Changes look good @Arkatufus
| var capturedException = ExceptionDispatchInfo.Capture(ex); | ||
| using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)); | ||
| await StopAsync(cts.Token); | ||
| capturedException.Throw(); |
Changes
close #470 - application crashes and exits should always be explicitly logged someplace where they can be seen regardless of logging configuration.
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):
AkkaHostedServiceget eaten / not logged #470