本文整理匯總了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);
}