當前位置: 首頁>>代碼示例>>C#>>正文


C# SimpleLayout.Initialize方法代碼示例

本文整理匯總了C#中NLog.Layouts.SimpleLayout.Initialize方法的典型用法代碼示例。如果您正苦於以下問題:C# SimpleLayout.Initialize方法的具體用法?C# SimpleLayout.Initialize怎麽用?C# SimpleLayout.Initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NLog.Layouts.SimpleLayout的用法示例。


在下文中一共展示了SimpleLayout.Initialize方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: LayoutRendererThrows

 public void LayoutRendererThrows()
 {
     ConfigurationItemFactory configurationItemFactory = new ConfigurationItemFactory();
     configurationItemFactory.LayoutRenderers.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer));
     var cfg = new LoggingConfiguration(configurationItemFactory);
     SimpleLayout l = new SimpleLayout("xx${throwsException}yy", cfg);
     l.Initialize(cfg);
     string output = l.Render(LogEventInfo.CreateNullEvent());
     Assert.AreEqual("xxyy", output);
 }
開發者ID:ExM,項目名稱:NLog,代碼行數:10,代碼來源:SimpleLayoutOutputTests.cs

示例2: WrapperOverAgnostic

 public void WrapperOverAgnostic()
 {
     Layout l = new SimpleLayout("${rot13:${message}}");
     l.Initialize(null);
     Assert.True(l.IsThreadAgnostic);
 }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例3: AgnosticPlusAgnostic

 public void AgnosticPlusAgnostic()
 {
     Layout l = new SimpleLayout("${message}${level}${logger}");
     l.Initialize(null);
     Assert.True(l.IsThreadAgnostic);
 }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例4: AgnosticPlusNonAgnostic

 public void AgnosticPlusNonAgnostic()
 {
     Layout l = new SimpleLayout("${message}${threadname}");
     l.Initialize(null);
     Assert.False(l.IsThreadAgnostic);
 }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例5: NonThreadAgnosticTest

 public void NonThreadAgnosticTest()
 {
     Layout l = new SimpleLayout("${threadname}");
     l.Initialize(null);
     Assert.False(l.IsThreadAgnostic);
 }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例6: ThreadAgnosticTest

 public void ThreadAgnosticTest()
 {
     Layout l = new SimpleLayout("${message}");
     l.Initialize(null);
     Assert.True(l.IsThreadAgnostic);
 }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例7: CustomAgnosticTests

        public void CustomAgnosticTests()
        {
            var cif = new ConfigurationItemFactory();
            cif.RegisterType(typeof(CustomRendererAgnostic), string.Empty);

            Layout l = new SimpleLayout("${customAgnostic}", cif);

            l.Initialize(null);
            Assert.True(l.IsThreadAgnostic);
        }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:10,代碼來源:ThreadAgnosticTests.cs

示例8: TripleWrapperOverNonAgnostic

 public void TripleWrapperOverNonAgnostic()
 {
     Layout l = new SimpleLayout("${uppercase:${lowercase:${rot13:${message}${threadname}}}}");
     l.Initialize(null);
     Assert.False(l.IsThreadAgnostic);
 }
開發者ID:njannink,項目名稱:sonarlint-vs,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例9: SimpleLayoutCachingTest

 public void SimpleLayoutCachingTest()
 {
     var l = new SimpleLayout("xx${level}yy");
     var ev = LogEventInfo.CreateNullEvent();
     l.Initialize(CommonCfg);
     string output1 = l.Render(ev);
     string output2 = l.Render(ev);
     Assert.AreSame(output1, output2);
 }
開發者ID:ExM,項目名稱:NLog,代碼行數:9,代碼來源:SimpleLayoutOutputTests.cs

示例10: LayoutRendererThrows2

        public void LayoutRendererThrows2()
        {
            string internalLogOutput = RunAndCaptureInternalLog(
                () =>
                    {
                        ConfigurationItemFactory configurationItemFactory = new ConfigurationItemFactory();
                        configurationItemFactory.LayoutRenderers.RegisterDefinition("throwsException", typeof(ThrowsExceptionRenderer));

                        SimpleLayout l = new SimpleLayout("xx${throwsException:msg1}yy${throwsException:msg2}zz", new LoggingConfiguration(configurationItemFactory));
                        l.Initialize(CommonCfg);
                        string output = l.Render(LogEventInfo.CreateNullEvent());
                        Assert.AreEqual("xxyyzz", output);
                    },
                    LogLevel.Warn);

            Assert.IsTrue(internalLogOutput.IndexOf("msg1") >= 0, internalLogOutput);
            Assert.IsTrue(internalLogOutput.IndexOf("msg2") >= 0, internalLogOutput);
        }
開發者ID:ExM,項目名稱:NLog,代碼行數:18,代碼來源:SimpleLayoutOutputTests.cs

示例11: TripleWrapperOverAgnostic

 public void TripleWrapperOverAgnostic()
 {
     Layout l = new SimpleLayout("${uppercase:${lowercase:${rot13:${message}}}}");
     l.Initialize(CommonCfg);
     Assert.IsTrue(l.IsThreadAgnostic);
 }
開發者ID:ExM,項目名稱:NLog,代碼行數:6,代碼來源:ThreadAgnosticTests.cs

示例12: CustomNotAgnosticTests

        public void CustomNotAgnosticTests()
        {
            var cif = new ConfigurationItemFactory();
            cif.RegisterType(typeof(CustomRendererNonAgnostic), string.Empty);
            var cfg = new LoggingConfiguration(cif);
            Layout l = new SimpleLayout("${customNotAgnostic}", cfg);

            l.Initialize(cfg);
            Assert.IsFalse(l.IsThreadAgnostic);
        }
開發者ID:ExM,項目名稱:NLog,代碼行數:10,代碼來源:ThreadAgnosticTests.cs


注:本文中的NLog.Layouts.SimpleLayout.Initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。