From f29d19f452bb6ad1630e6357db8151550192879d Mon Sep 17 00:00:00 2001 From: Ruben Buniatyan Date: Wed, 11 Dec 2024 22:53:05 +0100 Subject: [PATCH] Prevent file logging before configuration initialization (#7896) --- src/Nethermind/Nethermind.Logging.NLog/NLogManager.cs | 5 +++++ src/Nethermind/Nethermind.Runner/Program.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Logging.NLog/NLogManager.cs b/src/Nethermind/Nethermind.Logging.NLog/NLogManager.cs index 9351177bdb1..426736e4d6d 100644 --- a/src/Nethermind/Nethermind.Logging.NLog/NLogManager.cs +++ b/src/Nethermind/Nethermind.Logging.NLog/NLogManager.cs @@ -20,6 +20,11 @@ public class NLogManager : ILogManager, IDisposable private const string DefaultFileTargetName = "file-async_wrapped"; private const string DefaultFolder = "logs"; + /// + /// The constructor to use when the configuration is not yet initialized. + /// + public NLogManager() { /* Log in temp dir? */ } + public NLogManager(string logFileName, string logDirectory = null, string logRules = null) { Setup(logFileName, logDirectory, logRules); diff --git a/src/Nethermind/Nethermind.Runner/Program.cs b/src/Nethermind/Nethermind.Runner/Program.cs index 7444a9830c8..f98f3503dc6 100644 --- a/src/Nethermind/Nethermind.Runner/Program.cs +++ b/src/Nethermind/Nethermind.Runner/Program.cs @@ -348,7 +348,7 @@ void ConfigureLogger(ParseResult parseResult) return; } - using NLogManager logManager = new("nethermind.log"); + using NLogManager logManager = new(); logger = logManager.GetClassLogger();