diff --git a/XenServerHealthCheck/ServerListHelper.cs b/XenServerHealthCheck/ServerListHelper.cs index d8b45ca0e..b786c5946 100755 --- a/XenServerHealthCheck/ServerListHelper.cs +++ b/XenServerHealthCheck/ServerListHelper.cs @@ -62,7 +62,7 @@ namespace XenServerHealthCheck } catch (Exception exn) { - log.Error(exn, exn); + log.Error("Decrypt server information failed", exn); } } } @@ -159,7 +159,7 @@ namespace XenServerHealthCheck } catch (Exception exp) { - log.Error(exp, exp); + log.Error("Get server list from XenCenter failed", exp); } return encServerList; diff --git a/XenServerHealthCheck/XenServerHealthCheck.cs b/XenServerHealthCheck/XenServerHealthCheck.cs index 56d916a83..bf522c4bc 100755 --- a/XenServerHealthCheck/XenServerHealthCheck.cs +++ b/XenServerHealthCheck/XenServerHealthCheck.cs @@ -31,6 +31,8 @@ using System; using System.ServiceProcess; +using System.Reflection; +using System.IO; namespace XenServerHealthCheck { @@ -41,6 +43,7 @@ namespace XenServerHealthCheck /// static void Main() { + log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(Assembly.GetCallingAssembly().Location + ".config")); ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { diff --git a/XenServerHealthCheck/XenServerHealthCheckService.cs b/XenServerHealthCheck/XenServerHealthCheckService.cs index 1e6c8103f..3900679ca 100755 --- a/XenServerHealthCheck/XenServerHealthCheckService.cs +++ b/XenServerHealthCheck/XenServerHealthCheckService.cs @@ -56,6 +56,7 @@ namespace XenServerHealthCheck protected override void OnStart(string[] args) { // Set up a timer to trigger the uploading service. + log.Info("XenServer Health Check Service starting..."); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 30 * 60000; // 30 minitues timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer); @@ -64,15 +65,18 @@ namespace XenServerHealthCheck protected override void OnStop() { + log.Info("XenServer Health Check Service stopping..."); } public void OnTimer(object sender, System.Timers.ElapsedEventArgs args) { + log.Info("XenServer Health Check Service start to refresh uploading tasks"); List Connections = ServerListHelper.GetServerList(); foreach (IXenConnection connection in Connections) { + log.InfoFormat("Check server {0} with user {1}", connection.Hostname, connection.Username); Session _session = new Session(connection.Hostname, 80); _session.APIVersion = API_Version.LATEST; try diff --git a/XenServerHealthCheck/app.config b/XenServerHealthCheck/app.config index cb2586beb..85260dc05 100755 --- a/XenServerHealthCheck/app.config +++ b/XenServerHealthCheck/app.config @@ -1,3 +1,26 @@ - + +
+ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file