public void Should_log_all_events() { ConfigureWithDefault(); for (int i = 0; i < 1000; i++) { _target.Info(i); } LogManager.Shutdown(); Consumer.LogData[] msgs = Consumer.GetAllMessages().ToArray(); msgs.Should().Have.Count.EqualTo(1000); }
public void Should_log_basic_information() { ConfigureWithDefault(); _target.Info("a log"); LogManager.Shutdown(); Consumer.LogData ev = Consumer.GetAllMessages().First(); ev.Domain.Should().Be.EqualTo(AppDomain.CurrentDomain.FriendlyName); ev.Level.Should().Be.EqualTo("INFO"); ev.Logger.Should().Be.EqualTo("Test"); ev.Thread.Should().Be.EqualTo(Thread.CurrentThread.Name); ev.UserName.Should().Be.EqualTo(WindowsIdentity.GetCurrent().Name); ev.Message.Should().Be.EqualTo("a log"); ev.TimeStamp.Should().Be.IncludedIn(DateTime.Now.AddMinutes(-10), DateTime.Now.AddMinutes(10)); }
public void Should_log_context_properties() { ConfigureWithDefault(); GlobalContext.Properties.Clear(); ThreadContext.Properties.Clear(); ThreadContext.Properties["threadContextProperty"] = "value"; _target.Info("a log"); LogManager.Shutdown(); Consumer.LogData ev = Consumer.GetAllMessages().First(); ev.Properties.Should().Have.Count.EqualTo(1); ev.Properties.First().Name.Should().Be.EqualTo("threadContextProperty"); ev.Properties.First().Value.Should().Be.EqualTo("value"); }
public void Should_log_exception() { ConfigureWithDefault(); try { throw new ApplicationException("exc msg"); } catch (Exception e) { _target.Info("a log", e); } LogManager.Shutdown(); Consumer.LogData ev = Consumer.GetAllMessages().First(); ev.Exception.Should().Contain("exc msg"); }