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 Warn_LambdaMessage() { // Prepare const string message = "Simple Message"; logger.Setup(l => l.Write( LogEventLevel.Warning, message, null)) .Verifiable(); log = new SerilogLogger(logger.Object); // Act log.Warn(message); // Assert logger.VerifyAll(); }
public void Warn_MessageWithException() { // Prepare const string message = "Exception occurred"; var ex = new Exception(message); logger.Setup(l => l.Write( LogEventLevel.Warning, ex, message, null)) .Verifiable(); log = new SerilogLogger(logger.Object); // Act log.Warn(message, ex); // Assert logger.VerifyAll(); }