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


C# PatternLayout.AddConverter方法代碼示例

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


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

示例1: addConveters

 private void addConveters(PatternLayout patternLayout)
 {
     foreach (ConverterInfo conveterInfo in m_converters)
     {
         patternLayout.AddConverter(conveterInfo);
     }
 }
開發者ID:ittray,項目名稱:LocalDemo,代碼行數:7,代碼來源:PatternLayoutAdoNetAppender.cs

示例2: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var patternLayout = new PatternLayout();
            patternLayout.AddConverter("rfc3339", typeof(Rfc3339Converter));
            patternLayout.ConversionPattern = "%rfc3339 %level %message%newline";
            patternLayout.ActivateOptions();

            var a = new TextboxAppender(this.textBoxProgress)
            {
                Layout = patternLayout,
                Threshold = Level.Debug,
                Name = textBoxProgress.Name,
            };
            a.ActivateOptions();
            appender = a;

            ((Hierarchy)log4net.LogManager.GetRepository()).Root.AddAppender(appender);
        }
開發者ID:sidiandi,項目名稱:ttaudio,代碼行數:20,代碼來源:TaskForm.cs

示例3: TestAddingCustomPattern

		[Test] public void TestAddingCustomPattern()
		{
			StringAppender stringAppender = new StringAppender();
			PatternLayout layout = new PatternLayout();

			layout.AddConverter("TestAddingCustomPattern", typeof(TestMessagePatternConverter));
			layout.ConversionPattern = "%TestAddingCustomPattern";
			layout.ActivateOptions();

			stringAppender.Layout = layout;

			ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
			BasicConfigurator.Configure(rep, stringAppender);

			ILog log1 = LogManager.GetLogger(rep.Name, "TestAddingCustomPattern");

			log1.Info("TestMessage");
			Assert.AreEqual("TestMessage", stringAppender.GetString(), "%TestAddingCustomPattern not registered");
			stringAppender.Reset();	
		}
開發者ID:aj9251,項目名稱:pandorasbox3,代碼行數:20,代碼來源:PatternLayoutTest.cs

示例4: NamedPatternConverterWithPrecision2ShouldStripLessLeadingStuffIfPresent

        public void NamedPatternConverterWithPrecision2ShouldStripLessLeadingStuffIfPresent() {
            StringAppender stringAppender = new StringAppender();
            PatternLayout layout = new PatternLayout();
            layout.AddConverter("message-as-name", typeof(MessageAsNamePatternConverter));
            layout.ConversionPattern = "%message-as-name{2}";
            layout.ActivateOptions();
            stringAppender.Layout = layout;
            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            BasicConfigurator.Configure(rep, stringAppender);
            ILog log1 = LogManager.GetLogger(rep.Name, "TestAddingCustomPattern");

            log1.Info("NoDots");
            Assert.AreEqual("NoDots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("One.Dot");
            Assert.AreEqual("One.Dot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("Tw.o.Dots");
            Assert.AreEqual("o.Dots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("TrailingDot.");
            Assert.AreEqual("TrailingDot.", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".LeadingDot");
            Assert.AreEqual("LeadingDot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            // empty string and other evil combinations as tests for of-by-one mistakes in index calculations
            log1.Info(string.Empty);
            Assert.AreEqual(string.Empty, stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("x");
            Assert.AreEqual("x", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".");
            Assert.AreEqual(".", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();
        }
開發者ID:Redi0,項目名稱:meijing-ui,代碼行數:44,代碼來源:PatternLayoutTest.cs


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