Example #1
0
        private async static Task TestRandomLoggingAsync()
        {
            try
            {
                var ipsum = await BaconIpsumClient.GetAsync();

                var random = new Random();

                var dice = random.Next(1, 7);

                switch (dice)
                {
                case 1:
                {
                    await Log4netLogger.Instance.LogDebugAsync(ipsum);

                    break;
                }

                case 2:
                {
                    await Log4netLogger.Instance.LogErrorAsync(ipsum);

                    break;
                }

                case 3:
                {
                    await Log4netLogger.Instance.LogFatalAsync(ipsum);

                    break;
                }

                case 4:
                {
                    await Log4netLogger.Instance.LogInformationAsync(ipsum);

                    break;
                }

                case 5:
                {
                    await Log4netLogger.Instance.LogWarningAsync(ipsum);

                    break;
                }

                case 6:
                {
                    await Log4netLogger.Instance.LogErrorAsync("bad luck", new Exception("no meat today"));

                    break;
                }
                }
            }
            catch (Exception ex)
            {
                await Log4netLogger.Instance.LogErrorAsync("Error trying to do something", ex);
            }
        }
Example #2
0
        private static void TestRandomLogging(int i)
        {
            try
            {
                var ipsum = BaconIpsumClient.Get();

                var random = new Random();

                var dice = random.Next(1, 7);

                switch (dice)
                {
                case 1:
                {
                    Logger.Instance.LogDebug(ipsum);
                    break;
                }

                case 2:
                {
                    Logger.Instance.LogError(ipsum);
                    break;
                }

                case 3:
                {
                    Logger.Instance.LogFatal(ipsum);
                    break;
                }

                case 4:
                {
                    Logger.Instance.LogInformation(ipsum);
                    break;
                }

                case 5:
                {
                    Logger.Instance.LogWarning(ipsum);
                    break;
                }

                case 6:
                {
                    Logger.Instance.LogError("bad luck", new Exception("no meat today"));
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.LogError("Error trying to do something", ex);
            }
        }