diff --git a/src/Topshelf/HostFactory.cs b/src/Topshelf/HostFactory.cs index 960f8f68..ac54f525 100644 --- a/src/Topshelf/HostFactory.cs +++ b/src/Topshelf/HostFactory.cs @@ -62,6 +62,7 @@ public static Host New(Action configureCallback) catch (Exception ex) { HostLogger.Get(typeof(HostFactory)).Error("An exception occurred creating the host", ex); + HostLogger.Shutdown(); throw; } } @@ -82,7 +83,8 @@ public static TopshelfExitCode Run(Action configureCallback) { HostLogger.Get(typeof(HostFactory)) .Error("The service terminated abnormally", ex); - + HostLogger.Shutdown(); + return TopshelfExitCode.AbnormalExit; } }