Exemplo n.º 1
0
        /// <summary>
        /// Add a rule for alle loglevels.
        /// </summary>
        /// <param name="target">Target to be written to when the rule matches.</param>
        /// <param name="loggerNamePattern">Logger name pattern. It may include the '*' wildcard at the beginning, at the end or at both ends.</param>
        public void AddRuleForAllLevels(Target target, string loggerNamePattern = "*")
        {
            var loggingRule = new LoggingRule(loggerNamePattern, target);

            loggingRule.EnableLoggingForLevels(LogLevel.MinLevel, LogLevel.MaxLevel);
            LoggingRules.Add(loggingRule);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add a rule for one loglevel.
        /// </summary>
        /// <param name="level">log level needed to trigger this rule. </param>
        /// <param name="target">Target to be written to when the rule matches.</param>
        /// <param name="loggerNamePattern">Logger name pattern. It may include the '*' wildcard at the beginning, at the end or at both ends.</param>
        public void AddRuleForOneLevel(LogLevel level, Target target, string loggerNamePattern = "*")
        {
            var loggingRule = new LoggingRule(loggerNamePattern, target);

            loggingRule.EnableLoggingForLevel(level);
            LoggingRules.Add(loggingRule);
        }
        public DefaultNLogConfiguration()
        {
            var consoleTarget = new ColoredConsoleTarget {
                Layout = @"${date:format=HH\:mm\:ss} ${logger} ${message}"
            };
            var rule1 = new LoggingRule("*", LogLevel.Trace, consoleTarget);

            AddTarget("_default_console", consoleTarget);
            LoggingRules.Add(rule1);
        }
Exemplo n.º 4
0
 public TestLoggingConfiguration()
 {
     Target = new TestTarget();
     LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, Target));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add a rule with min- and maxLevel.
 /// </summary>
 /// <param name="minLevel">Minimum log level needed to trigger this rule.</param>
 /// <param name="maxLevel">Maximum log level needed to trigger this rule.</param>
 /// <param name="target">Target to be written to when the rule matches.</param>
 /// <param name="loggerNamePattern">Logger name pattern. It may include the '*' wildcard at the beginning, at the end or at both ends.</param>
 public void AddRule(LogLevel minLevel, LogLevel maxLevel, Target target, string loggerNamePattern = "*")
 {
     LoggingRules.Add(new LoggingRule(loggerNamePattern, minLevel, maxLevel, target));
 }