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


C# Logger.LogError方法代码示例

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


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

示例1: LogErrorToJsonInputAsync

        public void LogErrorToJsonInputAsync()
        {
            var textInput = "e6d64ac2-c8e9-45e0-ac73-3298ff8cb96f";
            LogglyConfiguration.Configure(c => c.AuthenticateWith("csharptests", "Passw0rd!"));

            var logger = new Logger(textInput);
            var randomString = GenerateRandomString(8);
            logger.LogError(randomString, new InvalidOperationException("oops" + randomString + " something went wrong"));

            var signal = new AutoResetEvent(false);
            SearchJsonResponse response = null;

            new Thread(() =>
            {
                var running = true;
                while (running)
                {
                    Thread.Sleep(3000);
                    response = new Searcher("csharptests").SearchJson("exception", "oops" + randomString);

                    if (response.TotalRecords > 0)
                        running = false;
                }

                signal.Set();
            }).Start();

            signal.WaitOne(50 * 1000); // wait till loggly index the new event (if it didn't after 50 seconds it is broken)

            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.TotalRecords);
            Assert.AreEqual(randomString, response.Results[0].Json["message"]);
            Assert.AreEqual("error", response.Results[0].Json["category"]);
            Assert.AreEqual("System.InvalidOperationException: oops" + randomString + " something went wrong", response.Results[0].Json["exception"]);
        }
开发者ID:auth10,项目名称:loggly-csharp,代码行数:35,代码来源:IntegrationTests.cs

示例2: LogErrorTest

 public void LogErrorTest()
 {
     Scrabble.Logger tempLog = new Logger();
     tempLog.LogError("Error...", "Unit Test");
     string inFile = System.IO.File.ReadAllText(System.IO.Directory.GetCurrentDirectory() + "\\Logs\\" + tempLog.now + "_VERBOSE_LOG.txt");
     Console.Write(inFile);
     Assert.IsFalse(inFile.Equals("!!!!!!!ERROR - " + "Unit Test" + ": " + "Error..." + " !!!!!!!"));
 }
开发者ID:murple13,项目名称:Scrabble_CS3450,代码行数:8,代码来源:LoggerTests.cs

示例3: LoggerLogsError

        public void LoggerLogsError()
        {
            // Setup
            IDocumentStore store = Global.GetInMemoryStore();
            Logger logger = new Logger(store);

            DateTime date = DateTime.Now;
            Exception exception = new Exception("Here is the message");

            // Act
            logger.LogError(exception, "StoryNotFoundInRepository");

            // Assert
            using (var session = store.OpenSession())
            {
                LogError savedError = (from e in session.Query<LogError>() select e).First();
                Assert.GreaterOrEqual(savedError.DateOfOccurence, date.AddMinutes(-1));
                Global.PropertyValuesAreEquals(exception, savedError.Exception);
                Assert.AreEqual(savedError.ErrorCode, "StoryNotFoundInRepository");
            }
        }
开发者ID:TurkoAmericano,项目名称:OneWordStory,代码行数:21,代码来源:LoggerTests.cs


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