コード例 #1
0
        public void BasicLogLevelTest()
        {
            var infoSink  = new TestLogEventSink();
            var debugSink = new TestLogEventSink();

            ILog log = SerilogRobe.CreateLogger(configuration =>
            {
                configuration
                .WriteTo.Sink(debugSink)
                .WriteTo.Sink(infoSink, restrictedToMinimumLevel: LogEventLevel.Information);

                return(configuration);
            });

            log.Debug("debug 1");
            log.Debug("debug 2: {Message}", "foo");
            log.Info("info 1");
            log.Info("info 2: {AnotherMessage:l}", "bar");

            Assert.Equal(4, debugSink.Events.Count);
            Assert.Equal(2, infoSink.Events.Count);

            Assert.Contains("debug 2: \"foo\"", debugSink.Events.Select(e => e.RenderMessage()));
            Assert.Contains("info 2: bar", debugSink.Events.Select(e => e.RenderMessage()));
        }
コード例 #2
0
        public LoggerInjectionTests()
        {
            m_container = ContainerFactory.Create <TestContainerConfig>();

            m_testSink = m_container.GetInstance <TestLogEventSink>();
        }