Skip to content
Snippets Groups Projects
Commit ec0fc75d authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Make load monitoring log level configurable

This introduces a new optional configuration parameter called
"LogLevelMonitoring" to adjust the log level of those messages related
to the load monitoring of the service.

Fixes #50
parent e09905f8
No related branches found
No related tags found
No related merge requests found
...@@ -78,6 +78,11 @@ namespace ATxCommon.Serializables ...@@ -78,6 +78,11 @@ namespace ATxCommon.Serializables
/// </summary> /// </summary>
public string LogLevel { get; set; } = "Info"; 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> /// <summary>
/// Enable debug messages from the RoboSharp library. Default: false. /// Enable debug messages from the RoboSharp library. Default: false.
/// </summary> /// </summary>
...@@ -255,6 +260,28 @@ namespace ATxCommon.Serializables ...@@ -255,6 +260,28 @@ namespace ATxCommon.Serializables
[XmlIgnore] [XmlIgnore]
public string ErrorPath => Path.Combine(ManagedPath, "ERROR"); 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 #endregion
...@@ -470,6 +497,7 @@ namespace ATxCommon.Serializables ...@@ -470,6 +497,7 @@ namespace ATxCommon.Serializables
"\n" + "\n" +
"############### OPTIONAL PARAMETERS ###############\n" + "############### OPTIONAL PARAMETERS ###############\n" +
$"LogLevel: {LogLevel}\n" + $"LogLevel: {LogLevel}\n" +
$"LogLevelMonitoring: {LogLevelMonitoring}\n" +
$"ServiceTimer: {ServiceTimer} ms\n" + $"ServiceTimer: {ServiceTimer} ms\n" +
$"MarkerFile: {MarkerFile}\n" + $"MarkerFile: {MarkerFile}\n" +
$"GracePeriod: {GracePeriod} days (" + $"GracePeriod: {GracePeriod} days (" +
......
...@@ -317,9 +317,11 @@ namespace ATxCommon.Serializables ...@@ -317,9 +317,11 @@ namespace ATxCommon.Serializables
Serialize(); Serialize();
if (suspended) { if (suspended) {
Log.Trace("Service suspended. Reason(s): [{0}]", description); Log.Log(_config.MonitoringLogLevel,
"Service suspended. Reason(s): [{0}]", description);
} else { } else {
Log.Trace("Service resuming operation ({0}).", description); Log.Log(_config.MonitoringLogLevel,
"Service resuming operation ({0}).", description);
} }
} }
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
<!-- LogLevel: one of "Warn", "Info", "Debug", "Trace" --> <!-- LogLevel: one of "Warn", "Info", "Debug", "Trace" -->
<LogLevel>Debug</LogLevel> <LogLevel>Debug</LogLevel>
<!-- LogLevelMonitoring: load monitoring log level, default "Trace". -->
<LogLevelMonitoring>Trace</LogLevelMonitoring>
<!-- DebugRoboSharp: enable debug messages from the RoboSharp library. --> <!-- DebugRoboSharp: enable debug messages from the RoboSharp library. -->
<DebugRoboSharp>true</DebugRoboSharp> <DebugRoboSharp>true</DebugRoboSharp>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment