本文整理汇总了C#中LogWriter.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# LogWriter.Configure方法的具体用法?C# LogWriter.Configure怎么用?C# LogWriter.Configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogWriter
的用法示例。
在下文中一共展示了LogWriter.Configure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReconfigureDoesNotDisposeListenersStillUsedInSpecialSources
public void ReconfigureDoesNotDisposeListenersStillUsedInSpecialSources()
{
var traceListener = new MockDisposableTraceListener();
var config = new LoggingConfiguration();
config.AddLogSource("General", traceListener);
var logWriter = new LogWriter(config);
logWriter.Configure((cfg) =>
{
cfg.LogSources.Clear();
cfg.AddLogSource("New", new DefaultTraceListener());
cfg.SpecialSources.AllEvents.Listeners.Add(traceListener);
});
Assert.AreEqual(0, traceListener.DisposedCalls);
}
示例2: ReconfigureDisposesUnusedListeners
public void ReconfigureDisposesUnusedListeners()
{
var traceListener = new MockDisposableTraceListener();
var config = new LoggingConfiguration();
config.AddLogSource("General", traceListener);
var logWriter = new LogWriter(config);
logWriter.Configure((cfg) =>
{
cfg.LogSources.Clear();
cfg.AddLogSource("New", new DefaultTraceListener());
});
Assert.AreEqual(1, traceListener.DisposedCalls);
}
示例3: ReconfigureTraceEnabled
public void ReconfigureTraceEnabled()
{
var config = new LoggingConfiguration();
config.IsTracingEnabled = false;
var logger = new LogWriter(config);
// Is it false?
logger.Configure(cfg => Assert.IsFalse(cfg.UseImpersonation));
// Toggle
logger.Configure(cfg => cfg.IsTracingEnabled = true);
// Did it change?
logger.Configure(cfg => Assert.IsTrue(cfg.IsTracingEnabled));
}
示例4: ReconfigureIsLoggingEnabled
public void ReconfigureIsLoggingEnabled()
{
var config = new LoggingConfiguration();
Assert.IsTrue(config.IsLoggingEnabled);
var logger = new LogWriter(config);
Assert.IsTrue(logger.IsLoggingEnabled());
// Disable logging
logger.Configure(cfg => cfg.IsLoggingEnabled = false);
Assert.IsFalse(logger.IsLoggingEnabled());
}
示例5: ReconfigureImpersonation
public void ReconfigureImpersonation()
{
var config = new LoggingConfiguration();
config.UseImpersonation = false;
var logger = new LogWriter(config);
// Is it false?
logger.Configure(cfg => Assert.IsFalse(cfg.UseImpersonation));
// Use impersonation
logger.Configure(cfg => cfg.UseImpersonation = true);
// Did it change?
logger.Configure(cfg => Assert.IsTrue(cfg.UseImpersonation));
}