本文整理汇总了C#中LogFactory类的典型用法代码示例。如果您正苦于以下问题:C# LogFactory类的具体用法?C# LogFactory怎么用?C# LogFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogFactory类属于命名空间,在下文中一共展示了LogFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FlushTests
public static void FlushTests()
{
var factory = new LogFactory();
factory.Flush();
factory.Flush(100);
factory.Flush(TimeSpan.FromSeconds(1));
}
示例2: EnableDisableLogging
public static void EnableDisableLogging()
{
var factory = new LogFactory();
factory.DisableLogging();
factory.EnableLogging();
factory.IsLoggingEnabled();
}
示例3: SessionFactory
public SessionFactory(Application app, MessageStoreFactory storeFactory, LogFactory logFactory, IMessageFactory messageFactory)
{
application_ = app;
messageStoreFactory_ = storeFactory;
logFactory_ = logFactory;
messageFactory_ = messageFactory ?? new DefaultMessageFactory();
}
示例4: SocketInitiator
public SocketInitiator(Application application, MessageStoreFactory storeFactory, SessionSettings settings, LogFactory logFactory)
: base(application, storeFactory, settings, logFactory)
{
app_ = application;
storeFactory_ = storeFactory;
settings_ = settings;
logFactory_ = logFactory;
}
示例5: Configuration_PrivateBinPathIsNull_DoesNotThrowWhen
public void Configuration_PrivateBinPathIsNull_DoesNotThrowWhen()
{
AppDomainHelper.PrivateBinPath = () => null;
var fakeFileSystem = A.Fake<IFileSystem>();
var factory = new LogFactory(fakeFileSystem);
var loggingConfiguration = factory.Configuration;
}
示例6: GenericGetCurrentClassLoggerTest
public void GenericGetCurrentClassLoggerTest()
{
LogFactory<MyLogger> lf = new LogFactory<MyLogger>();
MyLogger l1 = lf.GetCurrentClassLogger();
MyLogger l2 = lf.GetCurrentClassLogger();
Assert.Same(l1, l2);
Assert.Equal("NLog.UnitTests.GetLoggerTests", l1.Name);
}
示例7: Configuration_PrivateBinPathIsNull_DoesNotThrow
public void Configuration_PrivateBinPathIsNull_DoesNotThrow()
{
var fakeAppDomain = A.Fake<IAppDomain>();
A.CallTo(() => fakeAppDomain.PrivateBinPath).Returns(null);
LogFactory.CurrentAppDomain = fakeAppDomain;
var fakeFileSystem = A.Fake<IFileSystem>();
var factory = new LogFactory(fakeFileSystem);
var dummy = factory.Configuration;
}
示例8: Configuration_WithPrivateBinPath_CheckIfConfigFileExistsInPrivateBinPath
public void Configuration_WithPrivateBinPath_CheckIfConfigFileExistsInPrivateBinPath()
{
const string AnyDirectory = "C:\\any\\";
AppDomainHelper.PrivateBinPath = () => AnyDirectory;
var fakeFileSystem = A.Fake<IFileSystem>();
var factory = new LogFactory(fakeFileSystem);
var loggingConfiguration = factory.Configuration;
A.CallTo(() => fakeFileSystem.File.Exists(Path.Combine(AnyDirectory, "NLog.config"))).MustHaveHappened();
}
示例9: EnableAndDisableLogging
public void EnableAndDisableLogging()
{
LogFactory factory = new LogFactory();
#pragma warning disable 618
// In order Suspend => Resume
Assert.True(factory.IsLoggingEnabled());
factory.DisableLogging();
Assert.False(factory.IsLoggingEnabled());
factory.EnableLogging();
Assert.True(factory.IsLoggingEnabled());
#pragma warning restore 618
}
示例10: Session
public Session(
Application app, MessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
SessionSchedule sessionSchedule, int heartBtInt, LogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID)
{
this.Application = app;
this.SessionID = sessID;
this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
this.schedule_ = sessionSchedule;
this.msgFactory_ = msgFactory;
this.SenderDefaultApplVerID = senderDefaultApplVerID;
this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
if (this.SessionID.IsFIXT)
this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
else
this.ApplicationDataDictionary = this.SessionDataDictionary;
Log log;
if (null != logFactory)
log = logFactory.Create(sessID);
else
log = new NullLog();
state_ = new SessionState(log, heartBtInt)
{
MessageStore = storeFactory.Create(sessID)
};
this.PersistMessages = true;
this.ResetOnDisconnect = false;
this.SendRedundantResendRequests = false;
this.ValidateLengthAndChecksum = true;
this.CheckCompID = true;
this.MillisecondsInTimeStamp = true;
this.EnableLastMsgSeqNumProcessed = false;
this.MaxMessagesInResendRequest = 0;
this.SendLogoutBeforeTimeoutDisconnect = false;
this.IgnorePossDupResendRequests = false;
if (!IsSessionTime)
Reset("Out of SessionTime at construction");
else if (IsNewSession)
Reset("New session");
lock (sessions_)
{
sessions_[this.SessionID] = this;
}
this.Application.OnCreate(this.SessionID);
this.Log.OnEvent("Created session");
}
示例11: Configuration_WithPrivateBinPath_CheckIfConfigFileExistsInPrivateBinPath
public void Configuration_WithPrivateBinPath_CheckIfConfigFileExistsInPrivateBinPath()
{
const string AnyDirectory = "C:\\any\\";
var fakeAppDomain = A.Fake<IAppDomain>();
A.CallTo(() => fakeAppDomain.PrivateBinPath).Returns(new[] { AnyDirectory });
LogFactory.CurrentAppDomain = fakeAppDomain;
var fakeFileSystem = A.Fake<IFileSystem>();
var factory = new LogFactory(fakeFileSystem);
var dummy = factory.Configuration;
A.CallTo(() => fakeFileSystem.File.Exists(Path.Combine(AnyDirectory, "NLog.config"))).MustHaveHappened();
}
示例12: GenericGetLoggerTest
public void GenericGetLoggerTest()
{
LogFactory<MyLogger> lf = new LogFactory<MyLogger>();
MyLogger l1 = lf.GetLogger("AAA");
MyLogger l2 = lf.GetLogger("AAA");
MyLogger l3 = lf.GetLogger("BBB");
Assert.Same(l1, l2);
Assert.NotSame(l1, l3);
Assert.Equal("AAA", l1.Name);
Assert.Equal("BBB", l3.Name);
}
示例13: Write
internal static void Write(Type loggerType, TargetWithFilterChain targets, LogEventInfo logEvent, LogFactory factory)
{
if (targets == null)
{
return;
}
#if !NET_CF
StackTraceUsage stu = targets.GetStackTraceUsage();
if (stu != StackTraceUsage.None && !logEvent.HasStackTrace)
{
StackTrace stackTrace;
#if !SILVERLIGHT
stackTrace = new StackTrace(StackTraceSkipMethods, stu == StackTraceUsage.WithSource);
#else
stackTrace = new StackTrace();
#endif
int firstUserFrame = FindCallingMethodOnStackTrace(stackTrace, loggerType);
logEvent.SetStackTrace(stackTrace, firstUserFrame);
}
#endif
int originalThreadId = Thread.CurrentThread.ManagedThreadId;
AsyncContinuation exceptionHandler = ex =>
{
if (ex != null)
{
if (factory.ThrowExceptions && Thread.CurrentThread.ManagedThreadId == originalThreadId)
{
throw new NLogRuntimeException("Exception occurred in NLog", ex);
}
}
};
for (var t = targets; t != null; t = t.NextInChain)
{
if (!WriteToTargetWithFilterChain(t, logEvent, exceptionHandler))
{
break;
}
}
}
示例14: Session
/// FIXME
public Session(
Application app, MessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
SessionSchedule sessionSchedule, int heartBtInt, LogFactory logFactory, IMessageFactory msgFactory)
{
this.Application = app;
this.SessionID = sessID;
this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
this.schedule_ = sessionSchedule;
this.msgFactory_ = msgFactory;
this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
if (this.SessionID.IsFIXT)
this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
else
this.ApplicationDataDictionary = this.SessionDataDictionary;
Log log;
if (null != logFactory)
log = logFactory.Create(sessID);
else
log = new NullLog();
state_ = new SessionState(log, heartBtInt);
state_.MessageStore = storeFactory.Create(sessID);
this.PersistMessages = true;
this.ResetOnDisconnect = false;
this.SendRedundantResendRequests = false;
this.ValidateLengthAndChecksum = true;
this.CheckCompID = true;
if (!CheckSessionTime())
Reset();
lock (sessions_)
{
sessions_[this.SessionID] = this;
}
this.Application.OnCreate(this.SessionID);
this.Log.OnEvent("Created session");
}
示例15: TypedGetLoggerTest
public void TypedGetLoggerTest()
{
LogFactory lf = new LogFactory();
MyLogger l1 = (MyLogger)lf.GetLogger("AAA", typeof(MyLogger));
MyLogger l2 = (MyLogger)lf.GetLogger("AAA", typeof(MyLogger));
Logger l3 = lf.GetLogger("AAA", typeof(Logger));
Logger l4 = lf.GetLogger("AAA", typeof(Logger));
Logger l5 = lf.GetLogger("AAA");
Logger l6 = lf.GetLogger("AAA");
Assert.AreSame(l1, l2);
Assert.AreSame(l3, l4);
Assert.AreSame(l5, l6);
Assert.AreSame(l3, l5);
Assert.AreNotSame(l1, l3);
Assert.AreEqual("AAA", l1.Name);
Assert.AreEqual("AAA", l3.Name);
}