当前位置: 首页>>代码示例>>C#>>正文


C# ConsoleLogger.Info方法代码示例

本文整理汇总了C#中ConsoleLogger.Info方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleLogger.Info方法的具体用法?C# ConsoleLogger.Info怎么用?C# ConsoleLogger.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConsoleLogger的用法示例。


在下文中一共展示了ConsoleLogger.Info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main(string[] args)
        {
            // Automatically attached to Log Manager, and also sets it as the default logger to be used
            // from LogManager.Log

            var l = LogManager.CreateLogger<ColoredConsoleLogger>();

            // Default level is Trace, on Debug builds, and Warn+Trace on Release.
            LogManager.Logger.Level = LogLevel.Trace;

            // Calling the default logger:

            LogManager.Log("Hello");
            LogManager.LogAsync("Log the same async.");
            LogManager.Log(LogLevel.Critical, "This is critical!");

            // Alternate ways:

            // Exactly the same as above. This is how the above is implemented internally.

            LogManager.Logger.Critical("LM: Critical");
            LogManager.Logger.Error("LM: oops");
            LogManager.Logger.Warn("LM: warning, warning!!");
            LogManager.Logger.Info("LM: Hi!");

            LogManager.Logger.Debug("LM: Some debug data.");
            LogManager.Logger.Trace("LM: Yello");

            l.Critical("DIRECT: This should work as well.");

            var newLogger = new ConsoleLogger();
            newLogger.Level = LogLevel.Trace;
            newLogger.IsEnabled = true;
            newLogger.Info("DIRECT: SayHi!");

            LogManager.AttachLogger(newLogger, "new");

            var oldConsoleLogger = LogManager.GetLogger("new");
            oldConsoleLogger.Trace("INDIRECT: TRACE Info");

            LogManager.DisableAll();

            oldConsoleLogger.Info("INDIRECT: won't be printed..");

            LogManager.EnableAll();

            var cl = new CompositeLogger();
            cl.Level = LogLevel.Trace;

            cl.AttachTarget(oldConsoleLogger);
            cl.Critical("COMPOSITE: hi from composite!");
            cl.Info("COMPOSITE: Info");

            oldConsoleLogger.Info("Bye bye!");
        }
开发者ID:prasannavl,项目名称:SharpLog,代码行数:55,代码来源:Program.cs

示例2: InfoLogger

		public void InfoLogger()
		{
			ConsoleLogger log = new ConsoleLogger("Logger", LoggerLevel.Info);

			log.Debug("Some debug message");
			log.Info("Some info message");
			log.Error("Some error message");
			log.Fatal("Some fatal error message");
			log.Warn("Some warn message");

			String logcontents = outWriter.GetStringBuilder().ToString();
			
			StringWriter expected = new StringWriter();
			expected.WriteLine("[Info] 'Logger' Some info message");
			expected.WriteLine("[Error] 'Logger' Some error message");
			expected.WriteLine("[Fatal] 'Logger' Some fatal error message");
			expected.WriteLine("[Warn] 'Logger' Some warn message");
			
			Assert.AreEqual(expected.GetStringBuilder().ToString(), logcontents, "logcontents don't match");
		}
开发者ID:ralescano,项目名称:castle,代码行数:20,代码来源:ConsoleLoggerTestCase.cs

示例3: ConsoleLogger

 public void ConsoleLogger()
 {
     var logger = new ConsoleLogger();
     logger.Info("Test");
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:5,代码来源:ConsoleLoggerTests.cs


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