• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LogFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LogFactory的典型用法代码示例。如果您正苦于以下问题:C# LogFactory类的具体用法?C# LogFactory怎么用?C# LogFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LogFactory类属于命名空间,在下文中一共展示了LogFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FlushTests

 public static void FlushTests()
 {
     var factory = new LogFactory();
     factory.Flush();
     factory.Flush(100);
     factory.Flush(TimeSpan.FromSeconds(1));
 }
开发者ID:semirs,项目名称:CellAO,代码行数:7,代码来源:LogFactoryTests.cs


示例2: EnableDisableLogging

 public static void EnableDisableLogging()
 {
     var factory = new LogFactory();
     factory.DisableLogging();
     factory.EnableLogging();
     factory.IsLoggingEnabled();
 }
开发者ID:semirs,项目名称:CellAO,代码行数:7,代码来源:LogFactoryTests.cs


示例3: SessionFactory

 public SessionFactory(Application app, MessageStoreFactory storeFactory, LogFactory logFactory, IMessageFactory messageFactory)
 {
     application_ = app;
     messageStoreFactory_ = storeFactory;
     logFactory_ = logFactory;
     messageFactory_ = messageFactory ?? new DefaultMessageFactory();
 }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:7,代码来源:SessionFactory.cs


示例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;
 }
开发者ID:robertpi,项目名称:quickfixn,代码行数:8,代码来源:SocketInitiator.cs


示例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;
        }
开发者ID:sebfischer83,项目名称:NLog,代码行数:8,代码来源:LogFactoryTests.cs


示例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);
        }
开发者ID:MikeFH,项目名称:NLog,代码行数:10,代码来源:GetLoggerTests.cs


示例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;
        }
开发者ID:habakuk000,项目名称:NLog,代码行数:11,代码来源:LogFactoryTests.cs


示例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();
        }
开发者ID:sebfischer83,项目名称:NLog,代码行数:11,代码来源:LogFactoryTests.cs


示例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
 }
开发者ID:MikeFH,项目名称:NLog,代码行数:12,代码来源:LogFactoryTests.cs


示例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");
        }
开发者ID:atesio,项目名称:quickfixn,代码行数:53,代码来源:Session.cs


示例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();
        }
开发者ID:habakuk000,项目名称:NLog,代码行数:14,代码来源:LogFactoryTests.cs


示例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);
        }
开发者ID:MikeFH,项目名称:NLog,代码行数:14,代码来源:GetLoggerTests.cs


示例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;
                }
            }
        }
开发者ID:unhappy224,项目名称:NLog.IqMetrix,代码行数:45,代码来源:LoggerImpl.cs


示例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");
        }
开发者ID:kennystone,项目名称:quickfixn,代码行数:43,代码来源:Session.cs


示例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);
        }
开发者ID:semirs,项目名称:CellAO,代码行数:21,代码来源:GetLoggerTests.cs


示例16: TypedGetCurrentClassLoggerTest

        public void TypedGetCurrentClassLoggerTest()
        {
            LogFactory lf = new LogFactory();

            MyLogger l1 = (MyLogger)lf.GetCurrentClassLogger(typeof(MyLogger));
            MyLogger l2 = (MyLogger)lf.GetCurrentClassLogger(typeof(MyLogger));
            Logger l3 = lf.GetCurrentClassLogger(typeof(Logger));
            Logger l4 = lf.GetCurrentClassLogger(typeof(Logger));
            Logger l5 = lf.GetCurrentClassLogger();
            Logger l6 = lf.GetCurrentClassLogger();

            Assert.AreSame(l1, l2);
            Assert.AreSame(l3, l4);
            Assert.AreSame(l5, l6);
            Assert.AreSame(l3, l5);

            Assert.AreNotSame(l1, l3);

            Assert.AreEqual("NLog.UnitTests.GetLoggerTests", l1.Name);
            Assert.AreEqual("NLog.UnitTests.GetLoggerTests", l3.Name);
        }
开发者ID:semirs,项目名称:CellAO,代码行数:21,代码来源:GetLoggerTests.cs


示例17: AbstractInitiator

        public AbstractInitiator(Application app, MessageStoreFactory storeFactory, SessionSettings settings, LogFactory logFactory, IMessageFactory messageFactory)
        {
            settings_ = settings;

            HashSet<SessionID> definedSessions = settings.GetSessions();
            if (0 == definedSessions.Count)
                throw new ConfigError("No sessions defined");

            SessionFactory factory = new SessionFactory(app, storeFactory, logFactory, messageFactory);
            foreach (SessionID sessionID in definedSessions)
            {
                Dictionary dict = settings.Get(sessionID);
                if ("initiator".Equals(dict.GetString(SessionSettings.CONNECTION_TYPE)))
                {
                    sessionIDs_.Add(sessionID);
                    sessions_[sessionID] = factory.Create(sessionID, dict);
                    SetDisconnected(sessionID);
                }
            }

            if (0 == sessions_.Count)
                throw new ConfigError("No sessions defined for initiator");
        }
开发者ID:BobRoss79,项目名称:quickfixn,代码行数:23,代码来源:AbstractInitiator.cs


示例18: ReloadConfigOnTimer_DoesNotThrowConfigException_IfConfigReloadReturnsNull

        public void ReloadConfigOnTimer_DoesNotThrowConfigException_IfConfigReloadReturnsNull()
        {
            var loggingConfiguration = new ReloadNullConfiguration();
            LogManager.Configuration = loggingConfiguration;
            var logFactory = new LogFactory(loggingConfiguration);

            Assert.DoesNotThrow(() => logFactory.ReloadConfigOnTimer(loggingConfiguration));
        }
开发者ID:shadowca,项目名称:NLog,代码行数:8,代码来源:LogFactoryTests.cs


示例19: ReloadConfigOnTimer_DoesNotThrowConfigException_IfConfigChangedInBetween

        public void ReloadConfigOnTimer_DoesNotThrowConfigException_IfConfigChangedInBetween()
        {
            var loggingConfiguration = new LoggingConfiguration();
            LogManager.Configuration = loggingConfiguration;
            var logFactory = new LogFactory(loggingConfiguration);
            var differentConfiguration = new LoggingConfiguration();

            Assert.DoesNotThrow(() => logFactory.ReloadConfigOnTimer(differentConfiguration));
        }
开发者ID:shadowca,项目名称:NLog,代码行数:9,代码来源:LogFactoryTests.cs


示例20: LogReceiverForwardingService

 /// <summary>
 /// Initializes a new instance of the <see cref="LogReceiverForwardingService"/> class.
 /// </summary>
 /// <param name="logFactory">The log factory.</param>
 public LogReceiverForwardingService(LogFactory logFactory)
 {
     this.logFactory = logFactory;
 }
开发者ID:semirs,项目名称:CellAO,代码行数:8,代码来源:LogReceiverForwardingService.cs



注:本文中的LogFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LogLevel类代码示例发布时间:2022-05-24
下一篇:
C# LogEventLevel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap