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); }
public void Debug_FormatMessage() { // Prepare const string format = "Number of Call: {0} occurred"; logger.Setup(l => l.Write( LogEventLevel.Debug, format, 1)) .Verifiable(); log = new SerilogLogger(logger.Object); // Act log.DebugFormat(format, 1); // Assert logger.VerifyAll(); }