<PackageReference Include="NLog" Version="6.1.4" />

NLog.Config.LoggingConfiguration

public class LoggingConfiguration
Keeps logging configuration and provides simple API to modify it.

Gets all targets.

Gets a collection of named targets specified in the configuration.

public CultureInfo DefaultCultureInfo { get; set; }

Gets or sets the default culture info to use as FormatProvider.

public virtual IEnumerable<string> FileNamesToWatch { get; }

Gets the collection of file names which should be watched for changes by NLog.

public LogFactory LogFactory { get; }

Gets the factory that will be configured

public IList<LoggingRule> LoggingRules { get; }

Gets the collection of logging rules.

public IDictionary<string, Layout> Variables { get; }

Gets the variables defined in the configuration or assigned from API

Initializes a new instance of the LoggingConfiguration class.

public LoggingConfiguration(LogFactory logFactory)

Initializes a new instance of the LoggingConfiguration class.

public void AddRule(LogLevel minLevel, LogLevel maxLevel, string targetName, string loggerNamePattern = "*")

Add a rule with min- and maxLevel.

public void AddRule(LogLevel minLevel, LogLevel maxLevel, Target target, string loggerNamePattern = "*")

Add a rule with min- and maxLevel.

public void AddRule(LogLevel minLevel, LogLevel maxLevel, Target target, string loggerNamePattern, bool final)

Add a rule with min- and maxLevel.

public void AddRule(LoggingRule rule)

Add a rule object.

public void AddRuleForAllLevels(string targetName, string loggerNamePattern = "*")

Add a rule for all loglevels.

public void AddRuleForAllLevels(Target target, string loggerNamePattern = "*")

Add a rule for all loglevels.

public void AddRuleForAllLevels(Target target, string loggerNamePattern, bool final)

Add a rule for all loglevels.

public void AddRuleForOneLevel(LogLevel level, string targetName, string loggerNamePattern = "*")

Add a rule for one loglevel.

public void AddRuleForOneLevel(LogLevel level, Target target, string loggerNamePattern = "*")

Add a rule for one loglevel.

public void AddRuleForOneLevel(LogLevel level, Target target, string loggerNamePattern, bool final)

Add a rule for one loglevel.

public void AddTarget(Target target)

Registers the specified target object. The name of the target is read from Name.

public void AddTarget(string name, Target target)

Registers the specified target object under a given name.

public LoggingRule FindRuleByName(string ruleName)

Lookup the logging rule with matching RuleName

public Target FindTargetByName(string name)

Finds the target with the specified name.

public TTarget FindTargetByName<TTarget>(string name) where TTarget : Target

Finds the target with the specified name and specified type.

public void Install(InstallationContext installationContext)

Installs target-specific objects on current system.

protected void PrepareForReload(LoggingConfiguration oldConfig)

Allow this new configuration to capture state from the old configuration

public virtual LoggingConfiguration Reload()

Loads the NLog LoggingConfiguration from its original source (Ex. read from original config-file after it was updated)

public bool RemoveRuleByName(string ruleName)

Removes the specified named logging rule with matching RuleName

public void RemoveTarget(string name)

Removes the specified named target.

public void Uninstall(InstallationContext installationContext)

Uninstalls target-specific objects from current system.