From 89a6a22f1ea60867fbb2e49dc8e26aa2336277b8 Mon Sep 17 00:00:00 2001 From: Jury Soldatenkov Date: Wed, 3 Sep 2014 02:25:58 +0400 Subject: [PATCH] Flush log buffers if HostFactory.New or HostFactory.Run throw exception --- src/Topshelf/HostFactory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; } }