NLog.Config.LoggingConfiguration.RemoveTarget C# (CSharp) Method

RemoveTarget() public method

Removes the specified named target.
public RemoveTarget ( string name ) : void
name string /// Name of the target. ///
return void
        public void RemoveTarget(string name)
        {
            this.targets.Remove(name);
        }

Usage Example

Example #1
0
        public void AddTarget_testname()
        {
            var config = new LoggingConfiguration();
            config.AddTarget("name1", new FileTarget {Name = "File"});
            var allTargets = config.AllTargets;
            Assert.NotNull(allTargets);
            Assert.Equal(1, allTargets.Count);

            //maybe confusing, but the name of the target is not changed, only the one of the key.
            Assert.Equal("File", allTargets.First().Name);
            Assert.NotNull(config.FindTargetByName<FileTarget>("name1"));

            config.RemoveTarget("name1");
            allTargets = config.AllTargets;
            Assert.Equal(0, allTargets.Count);
        }
All Usage Examples Of NLog.Config.LoggingConfiguration::RemoveTarget