diff --git a/ATxCommon/Serializables/ServiceConfig.cs b/ATxCommon/Serializables/ServiceConfig.cs index bf65c98526a80ab9030fc7b83f13def00ee4b217..192fc32a7714bcf7c7370cc1695a0e6667851f7c 100644 --- a/ATxCommon/Serializables/ServiceConfig.cs +++ b/ATxCommon/Serializables/ServiceConfig.cs @@ -78,6 +78,11 @@ namespace ATxCommon.Serializables /// </summary> public string LogLevel { get; set; } = "Info"; + /// <summary> + /// Log level to use for performance monitoring messages. Default: "Trace" + /// </summary> + public string LogLevelMonitoring { get; set; } = "Trace"; + /// <summary> /// Enable debug messages from the RoboSharp library. Default: false. /// </summary> @@ -255,6 +260,28 @@ namespace ATxCommon.Serializables [XmlIgnore] public string ErrorPath => Path.Combine(ManagedPath, "ERROR"); + /// <summary> + /// The LogLevel to be used for performance monitoring messages. + /// </summary> + [XmlIgnore] + public LogLevel MonitoringLogLevel { + get { + switch (LogLevelMonitoring) { + case "Warn": + return global::NLog.LogLevel.Warn; + case "Info": + return global::NLog.LogLevel.Info; + case "Debug": + return global::NLog.LogLevel.Debug; + case "Trace": + return global::NLog.LogLevel.Trace; + default: + return global::NLog.LogLevel.Info; + } + } + } + + #endregion @@ -470,6 +497,7 @@ namespace ATxCommon.Serializables "\n" + "############### OPTIONAL PARAMETERS ###############\n" + $"LogLevel: {LogLevel}\n" + + $"LogLevelMonitoring: {LogLevelMonitoring}\n" + $"ServiceTimer: {ServiceTimer} ms\n" + $"MarkerFile: {MarkerFile}\n" + $"GracePeriod: {GracePeriod} days (" + diff --git a/ATxCommon/Serializables/ServiceStatus.cs b/ATxCommon/Serializables/ServiceStatus.cs index 8e0ec88a70c9f5bad0e8b3bbc88de325705715c1..fd015927d2eadf30457098307a7628274326f73a 100644 --- a/ATxCommon/Serializables/ServiceStatus.cs +++ b/ATxCommon/Serializables/ServiceStatus.cs @@ -317,9 +317,11 @@ namespace ATxCommon.Serializables Serialize(); if (suspended) { - Log.Trace("Service suspended. Reason(s): [{0}]", description); + Log.Log(_config.MonitoringLogLevel, + "Service suspended. Reason(s): [{0}]", description); } else { - Log.Trace("Service resuming operation ({0}).", description); + Log.Log(_config.MonitoringLogLevel, + "Service resuming operation ({0}).", description); } } diff --git a/Resources/conf/config.common.xml b/Resources/conf/config.common.xml index b472f537d85ea3649618349079d4d164e96f859f..75020662c089d60dbc5993e077df971ee89e4506 100644 --- a/Resources/conf/config.common.xml +++ b/Resources/conf/config.common.xml @@ -33,6 +33,9 @@ <!-- LogLevel: one of "Warn", "Info", "Debug", "Trace" --> <LogLevel>Debug</LogLevel> + <!-- LogLevelMonitoring: load monitoring log level, default "Trace". --> + <LogLevelMonitoring>Trace</LogLevelMonitoring> + <!-- DebugRoboSharp: enable debug messages from the RoboSharp library. --> <DebugRoboSharp>true</DebugRoboSharp>