2
votes

I tried to disable the particular log in nlog config and I added like this

logger name="*" minlevel="Trace" maxlevel="Trace" writeTo="t" enabled="false"

is working fine. I need to programmatically in c#.

1

1 Answers

3
votes

You need something like this:

        // lookup for the rule in NLog config
        var rule = LogManager
            .Configuration
            .LoggingRules                
            .FirstOrDefault(_ => _.LoggerNamePattern == "*");

        // disable the rule
        if (rule != null)            
            rule.DisableLoggingForLevel(LogLevel.Trace);