Hello,
I'm trying to change my logging level at runtime using the following code
var c = NLog.LogManager.Configuration;
var file = c.FindTargetByName("file") as FileTarget;
if (file == null)
return;
var rule = c.LoggingRules.FirstOrDefault(r => r.Targets.Contains(file));
if (rule == null)
return;
if (EnableDebug)
rule.EnableLoggingForLevel(LogLevel.Debug);
else
rule.DisableLoggingForLevel(LogLevel.Debug);
NLog.LogManager.ReconfigExistingLoggers();
However, this doesn't work. file and rule are both found, so it reaches the if-else statement correctly but calling NLog.LogManager.ReconfigExistingLoggers(); doesn't seem to affect existing loggers.
Hello,
I'm trying to change my logging level at runtime using the following code
However, this doesn't work. file and rule are both found, so it reaches the if-else statement correctly but calling NLog.LogManager.ReconfigExistingLoggers(); doesn't seem to affect existing loggers.