예제 #1
0
        public void Logging()
        {
            const string message       = "Error Message";
            const string messageFormat = "Message Format: message: {0}, exception: {1}";
            var          ex            = new Exception();

            var log = new SerilogLogger(GetType());

            Assert.IsNotNull(log);

            log.Debug(message);
            log.Debug(message, ex);
            log.DebugFormat(messageFormat, message, ex.Message);
            log.Debug(ex, messageFormat, messageFormat, ex);

            log.Error(message);
            log.Error(message, ex);
            log.ErrorFormat(messageFormat, message, ex.Message);
            log.Error(ex, messageFormat, messageFormat, ex);

            log.Fatal(message);
            log.Fatal(message, ex);
            log.FatalFormat(messageFormat, message, ex.Message);
            log.Fatal(ex, messageFormat, messageFormat, ex);

            log.Info(message);
            log.Info(message, ex);
            log.InfoFormat(messageFormat, message, ex.Message);
            log.Info(ex, messageFormat, messageFormat, ex);

            log.Warn(message);
            log.Warn(message, ex);
            log.WarnFormat(messageFormat, message, ex.Message);
            log.Warn(ex, messageFormat, messageFormat, ex);
        }
예제 #2
0
        public void Error_FormatMessage()
        {
            // Prepare
            const string format = "Number of Call: {0} occurred";

            logger.Setup(l => l.Write(
                             LogEventLevel.Error, format, 1))
            .Verifiable();
            log = new SerilogLogger(logger.Object);

            // Act
            log.ErrorFormat(format, 1);

            // Assert
            logger.VerifyAll();
        }