Example #1
0
        private static void ConfigRule(NLog.Config.LoggingRule rule, int minLevel)
        {
            //Disable all loglevel rules
            for (int i = 0; i < 6; i++)
            {
                rule.DisableLoggingForLevel(LogLevel.FromOrdinal(i));
            }

            //Enable present loglevel rules up to maxLevel
            if (minLevel > 0)
            {
                for (int i = 0; i <= minLevel; i++)
                {
                    var logLevel = LogLevel.FromOrdinal(6 - i);
                    if (logLevel != LogLevel.Off)
                        rule.EnableLoggingForLevel(logLevel);
                }
            }
        }