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
/// </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 (" +
......
......@@ -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);
}
}
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment