本文整理汇总了C#中NLog.Config.LoggingRule.DisableLoggingForLevel方法的典型用法代码示例。如果您正苦于以下问题:C# LoggingRule.DisableLoggingForLevel方法的具体用法?C# LoggingRule.DisableLoggingForLevel怎么用?C# LoggingRule.DisableLoggingForLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLog.Config.LoggingRule
的用法示例。
在下文中一共展示了LoggingRule.DisableLoggingForLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureLogger
private void ConfigureLogger(NLog.LogLevel nlogLogLevel)
{
var config = new LoggingConfiguration();
_target = new MemoryTarget {Layout = "${level:uppercase=true}|${message}|${exception}"};
config.AddTarget("memory", _target);
var loggingRule = new LoggingRule("*", NLog.LogLevel.Trace, _target);
loggingRule.DisableLoggingForLevel(nlogLogLevel);
config.LoggingRules.Add(loggingRule);
LogManager.Configuration = config;
_sut = new NLogLogProvider().GetLogger("Test");
}
示例2: ConfigureLogger
private void ConfigureLogger(NLog.LogLevel nlogLogLevel)
{
NLogLogManager.ProviderIsAvailableOverride = true;
var config = new LoggingConfiguration();
target = new MemoryTarget();
target.Layout = "${level:uppercase=true}|${message}|${exception}";
config.AddTarget("memory", target);
var loggingRule = new LoggingRule("*", LogLevel.Trace, target);
loggingRule.DisableLoggingForLevel(nlogLogLevel);
config.LoggingRules.Add(loggingRule);
NLog.LogManager.Configuration = config;
sut = new NLogLogManager().GetLogger("Test");
}
示例3: ChangeRuleMinLevel
private static void ChangeRuleMinLevel(LoggingRule rule, LogLevel minLevel)
{
/*
* Based on how the LoggingLevel initializes its logging levels when given a minLevel,
* but because LogLevel.MinLevel and LogLevel.MaxLevel are not publically accessible,
* their current values are hardcoded. TODO: This is fragile!
*/
for (var i = LogLevel.Trace.Ordinal; i < minLevel.Ordinal; i++)
{
rule.DisableLoggingForLevel(LogLevel.FromOrdinal(i));
}
for (var i = minLevel.Ordinal; i <= LogLevel.Fatal.Ordinal; i++)
{
rule.EnableLoggingForLevel(LogLevel.FromOrdinal(i));
}
LogManager.ReconfigExistingLoggers();
}
示例4: SetLogLevelForRule
private void SetLogLevelForRule(LoggingRule rule, LogLevel activeLogLevel)
{
// Reset all log levels to off
for (int i = MinLogLevel; i <= MaxLogLevel; i++)
{
rule.DisableLoggingForLevel(LogLevel.FromOrdinal(i));
}
// Enable the active log level and all levels numerically higher
for (int i = activeLogLevel.GetHashCode(); i <= MaxLogLevel; i++)
{
rule.EnableLoggingForLevel(LogLevel.FromOrdinal(i));
}
InternalLogger.Debug("*** Setting active log level for " + _logger.Name + " to " + activeLogLevel.Name);
}
示例5: ApplyLogLevel
private void ApplyLogLevel(LoggingRule rule, IList<LogLevel> levels)
{
foreach (var level in rule.Levels)
rule.DisableLoggingForLevel(level);
foreach (var level in levels)
rule.EnableLoggingForLevel(level);
}