From 4d623b5b5e8fe601f085fb59a7001cbff396a28a Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Mon, 23 Jul 2018 14:12:57 +0200 Subject: [PATCH] Move call to SetupMailLogging to LoadConfig That's the earliest place where setting up the mail logger is possible / makes sense, so do it right then. Additionally, the check for SmtpHost is redundant since it also done in the method called, so no need for it. --- ATxService/AutoTx.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 80e7f6d..2d9f6d5 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -285,7 +285,10 @@ namespace ATxService // this should terminate the service process: throw new Exception("Error loading configuration."); } + // update the file logger with the configured log level: SetupFileLogging(_config.LogLevel); + // the mail logger requires the configuration to be present, so we can call it now: + SetupMailLogging(); } /// <summary> @@ -311,10 +314,6 @@ namespace ATxService /// Check if loaded configuration is valid, print a summary to the log. /// </summary> private void CheckConfiguration() { - // non-critical / optional configuration parameters: - if (!string.IsNullOrWhiteSpace(_config.SmtpHost)) - SetupMailLogging(); - var configInvalid = false; if (FsUtils.CheckSpoolingDirectories(_config.IncomingPath, _config.ManagedPath) == false) { Log.Error("ERROR checking spooling directories (incoming / managed)!"); -- GitLab