当前位置: 首页>>代码示例>>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;未经允许,请勿转载。