Exemplo n.º 1
0
        static void ConfigureLogging(bool verbose)
        {
            var consoleAppender = new log4net.Appender.ConsoleAppender();
            consoleAppender.Layout = new log4net.Layout.PatternLayout("[%date{yyyy-MM-dd HH:mm:ss}] %-5p %c{1} - %m%n");

            if (!verbose) {
                var filter = new LoggerMatchFilter();
                filter.AcceptOnMatch = true;
                filter.LoggerToMatch = typeof(Program).ToString();
                consoleAppender.AddFilter(filter);

                consoleAppender.AddFilter(new DenyAllFilter());
            }

            log4net.Config.BasicConfigurator.Configure(consoleAppender);
        }
Exemplo n.º 2
0
        static void ConfigureLogging(bool verbose)
        {
            var consoleAppender = new log4net.Appender.ConsoleAppender();

            consoleAppender.Layout = new log4net.Layout.PatternLayout("[%date{yyyy-MM-dd HH:mm:ss}] %-5p %c{1} - %m%n");

            if (!verbose)
            {
                var filter = new LoggerMatchFilter();
                filter.AcceptOnMatch = true;
                filter.LoggerToMatch = typeof(Program).ToString();
                consoleAppender.AddFilter(filter);

                consoleAppender.AddFilter(new DenyAllFilter());
            }

            log4net.Config.BasicConfigurator.Configure(consoleAppender);
        }
Exemplo n.º 3
0
        private static void ConfigureLogging()
        {
            var repository      = LogManager.GetRepository(Assembly.GetEntryAssembly());
            var consoleAppender = new log4net.Appender.ConsoleAppender()
            {
                Layout = new log4net.Layout.SimpleLayout(),
            };

            var enablingFilter = new log4net.Filter.LoggerMatchFilter()
            {
                LoggerToMatch = nameof(Muwesome),
                AcceptOnMatch = true,
            };

            consoleAppender.AddFilter(enablingFilter);
            consoleAppender.AddFilter(new log4net.Filter.DenyAllFilter());

            log4net.Config.BasicConfigurator.Configure(repository, consoleAppender);
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            var appender = new log4net.Appender.ConsoleAppender();
            appender.Layout = new log4net.Layout.SimpleLayout();
            appender.AddFilter(new log4net.Filter.LevelRangeFilter { LevelMin = log4net.Core.Level.Info });
            log4net.Config.BasicConfigurator.Configure(appender);

            using (var connection = new MyConnection(new[] { "uri_0", "uri_1" }))
            {
                connection.Open();

                Console.WriteLine("Press enter to subscribe data and press again to exit.");
                Console.ReadLine();

                connection.Subscribe(new TestSubscriber("A"));
                connection.Subscribe(new TestSubscriber("B"));

                Console.ReadLine();
            }
        }
Exemplo n.º 5
0
        public override void Configure(string key, ILoggerRepository repository)
        {
            foreach (var level in Levels)
            {
                var appender = new log4net.Appender.ConsoleAppender();

                var layout = new PatternLayout(Pattern);
                layout.ActivateOptions();

                appender.Layout = layout;
                appender.Name   = key + "_" + level.ToString().ToLower();

                var filter = new LevelRangeFilter();
                filter.LevelMax = level;
                filter.LevelMin = level;
                filter.ActivateOptions();
                appender.AddFilter(filter);

                appender.ActivateOptions();

                BasicConfigurator.Configure(repository, appender);
            }
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            var appender = new log4net.Appender.ConsoleAppender();

            appender.Layout = new log4net.Layout.SimpleLayout();
            appender.AddFilter(new log4net.Filter.LevelRangeFilter {
                LevelMin = log4net.Core.Level.Info
            });
            log4net.Config.BasicConfigurator.Configure(appender);

            using (var connection = new MyConnection(new[] { "uri_0", "uri_1" }))
            {
                connection.Open();

                Console.WriteLine("Press enter to subscribe data and press again to exit.");
                Console.ReadLine();

                connection.Subscribe(new TestSubscriber("A"));
                connection.Subscribe(new TestSubscriber("B"));

                Console.ReadLine();
            }
        }