當前位置: 首頁>>代碼示例>>C#>>正文


C# ConsoleAppender.AddFilter方法代碼示例

本文整理匯總了C#中log4net.Appender.ConsoleAppender.AddFilter方法的典型用法代碼示例。如果您正苦於以下問題:C# ConsoleAppender.AddFilter方法的具體用法?C# ConsoleAppender.AddFilter怎麽用?C# ConsoleAppender.AddFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在log4net.Appender.ConsoleAppender的用法示例。


在下文中一共展示了ConsoleAppender.AddFilter方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ConfigureLog4Net

 private static void ConfigureLog4Net()
 {
     if (ConfigurationManager.GetSection("log4net") == null)
     {
         var layout = new SimpleLayout();
         layout.ActivateOptions();
         var consoleAppender = new ConsoleAppender
                                   {
                                       Layout = layout
                                   };
         consoleAppender.AddFilter(new LevelRangeFilter
                                       {
                                           LevelMin = Level.Info,
                                           LevelMax = Level.Fatal,
                                           AcceptOnMatch = false
                                       });
         consoleAppender.AddFilter(
             new LoggerMatchFilter
                 {
                     LoggerToMatch = "Remora",
                     AcceptOnMatch = true
                 }
             );
         consoleAppender.AddFilter(new DenyAllFilter());
         consoleAppender.ActivateOptions();
         BasicConfigurator.Configure(consoleAppender);
     }
     else
     {
         XmlConfigurator.Configure();
     }
 }
開發者ID:julienblin,項目名稱:Remora,代碼行數:32,代碼來源:Program.cs

示例2: Log4NetFiltering

        public Log4NetFiltering()
        {
            #region Log4NetFilterUsage

            ConsoleAppender appender = new ConsoleAppender
            {
                Threshold = Level.Debug,
                Layout = new SimpleLayout(),
            };

            appender.AddFilter(new NServiceBusLogFilter());
            appender.ActivateOptions();

            BasicConfigurator.Configure(appender);

            NServiceBus.Logging.LogManager.Use<Log4NetFactory>();

            #endregion
        }
開發者ID:odelljl,項目名稱:docs.particular.net,代碼行數:19,代碼來源:Log4NetFiltering.cs

示例3: SetupLogger

 private void SetupLogger()
 {
     Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
     PatternLayout patternLayout = new PatternLayout();
     patternLayout.ConversionPattern = "%date [%thread] %-5level [%class.%method] - %message%newline";
     patternLayout.ActivateOptions();
     RollingFileAppender roller = new RollingFileAppender();
     roller.AppendToFile = false;
     roller.File = @"ResultExporterLog.txt";
     roller.Layout = patternLayout;
     roller.MaxSizeRollBackups = 5;
     roller.MaximumFileSize = "1GB";
     roller.RollingStyle = RollingFileAppender.RollingMode.Size;
     roller.StaticLogFileName = true;
     roller.ActivateOptions();
     ConsoleAppender console = new ConsoleAppender();
     PatternLayout consolePatternLayout = new PatternLayout();
     consolePatternLayout.ConversionPattern = "%date [Testlink Result Exporter] [%level] %message%newline";
     consolePatternLayout.ActivateOptions();
     LevelRangeFilter consoleLevelFilter = new LevelRangeFilter();
     consoleLevelFilter.LevelMin = Level.Info;
     consoleLevelFilter.LevelMax = Level.Fatal;
     console.AddFilter(consoleLevelFilter);
     console.Layout = consolePatternLayout;
     hierarchy.Root.AddAppender(roller);
     hierarchy.Root.AddAppender(console);
     hierarchy.Root.Level = Level.All;
     hierarchy.Configured = true;
 }
開發者ID:christianeisendle,項目名稱:nunit-testlink-adapter,代碼行數:29,代碼來源:ResultExporter.cs

示例4: Main

		static void Main()
		{
			var consoleAppender = new ConsoleAppender
			{
				Layout = new SimpleLayout(),
			};
			consoleAppender.AddFilter(new LoggerMatchFilter
			{
				AcceptOnMatch = true,
				LoggerToMatch = "Raven.Client"
			});
			consoleAppender.AddFilter(new DenyAllFilter());
			BasicConfigurator.Configure(consoleAppender);

			// start 5 instances of Raven's servers
			Console.WriteLine("Starting...");
			DeleteDirectories("Users", "Blogs", "Posts.1", "Posts.2", "Posts.3");
			var ravenDbServers = StartServers();
			Console.WriteLine("All servers started...");

			var shards = new Shards
			{
				new DocumentStore
				{
					Identifier = "Users",
					Url = "http://localhost:8081",
					Conventions =
						{
							DocumentKeyGenerator = user => "users/" + ((User) user).Name
						}
				},
				new DocumentStore {Identifier = "Blogs", Url = "http://localhost:8082"},
				new DocumentStore {Identifier = "Posts #1", Url = "http://localhost:8083"},
				new DocumentStore {Identifier = "Posts #2", Url = "http://localhost:8084"},
				new DocumentStore {Identifier = "Posts #3", Url = "http://localhost:8085"}
			};

			var shardStrategy = new ShardStrategy
			{
				ShardAccessStrategy =new ParallelShardAccessStrategy(),
				ShardSelectionStrategy = new BlogShardSelectionStrategy(3),
				ShardResolutionStrategy = new BlogShardResolutionStrategy(3),
			};
			var documentStore = new ShardedDocumentStore(shardStrategy, shards);
			documentStore.Initialize();

			using(var session = documentStore.OpenSession())
			{
				var user = new User { Name = "ayende" };
				var blog = new Blog { Name = "Ayende @ Rahien" };

				session.Store(user);
				session.Store(blog);

				// we have to save to Raven to get the generated id for the blog instance
				session.SaveChanges();
				var posts = new List<Post>();
				for (var i = 0; i < 6; i++)
				{
					var post = new Post
					{
						BlogId = blog.Id,
						UserId = user.Id,
						Content = "Just a post",
						Title = "Post #" + (i + 1)
					};
					posts.Add(post);
					session.Store(post);
				}

				session.SaveChanges();
			}

			// queries
			using (var session = documentStore.OpenSession())
			{
				session.LuceneQuery<User>().WaitForNonStaleResults().ToArray();
				session.LuceneQuery<Blog>().WaitForNonStaleResults().ToArray();
				session.LuceneQuery<Post>().WaitForNonStaleResults().ToArray();
			}

			// loading
			using (var session = documentStore.OpenSession())
			{
				session.Load<User>("users/ayende");
				session.Load<Blog>("blogs/1");
				session.Load<Post>("posts/1/2");
				session.Load<Post>("posts/2/2");
			}

			documentStore.Dispose();

			foreach (var server in ravenDbServers)
			{
				server.Dispose();
			}
		}
開發者ID:VirtueMe,項目名稱:ravendb,代碼行數:97,代碼來源:Program.cs

示例5: ConfigureLog

        ILog ConfigureLog()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
            hierarchy.Root.RemoveAllAppenders();

            PatternLayout patternLayout = new PatternLayout();
            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            ConsoleAppender consoleErrAppender = new ConsoleAppender();
            consoleErrAppender.Layout = patternLayout;
            consoleErrAppender.ActivateOptions();
            consoleErrAppender.Target = "Console.Error";
            log4net.Filter.LevelRangeFilter errfilter = new log4net.Filter.LevelRangeFilter();
            errfilter.LevelMin = Level.Verbose;
            errfilter.LevelMax = Level.Emergency;
            consoleErrAppender.AddFilter(errfilter);
            hierarchy.Root.AddAppender(consoleErrAppender);

            hierarchy.Root.Level = Level.Info;
            if (verbose == true)
            {
                hierarchy.Root.Level = Level.Debug;
            }
            hierarchy.Configured = true;

            BasicConfigurator.Configure(new ConsoleAppender[] { consoleErrAppender });

            return LogManager.GetLogger(typeof(OpenSearchClient));
        }
開發者ID:Terradue,項目名稱:DotNetOpenSearchClient,代碼行數:30,代碼來源:OpenSearchClient.cs

示例6: RunInDebugMode

        private static void RunInDebugMode(AnonymousUserAccessMode? anonymousUserAccessMode, RavenConfiguration ravenConfiguration)
        {
			var consoleAppender = new ConsoleAppender
			{
				Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
			};
			consoleAppender.AddFilter(new LoggerMatchFilter
			{
				AcceptOnMatch = true,
				LoggerToMatch = typeof(HttpServer).FullName
			});
			consoleAppender.AddFilter(new DenyAllFilter());
			BasicConfigurator.Configure(consoleAppender);
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            while (RunServer(ravenConfiguration))
            {
                
            }
        }
開發者ID:plasmaboyer,項目名稱:ravendb,代碼行數:21,代碼來源:Program.cs

示例7: RunInDebugMode

        private static void RunInDebugMode(AnonymousUserAccessMode? anonymousUserAccessMode)
        {
			var consoleAppender = new ConsoleAppender
			{
				Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
			};
			consoleAppender.AddFilter(new LoggerMatchFilter
			{
				AcceptOnMatch = true,
				LoggerToMatch = typeof(HttpServer).FullName
			});
			consoleAppender.AddFilter(new DenyAllFilter());
			BasicConfigurator.Configure(consoleAppender);
            var ravenConfiguration = new RavenConfiguration();
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            using (new RavenDbServer(ravenConfiguration))
            {
                var path = Path.Combine(Environment.CurrentDirectory, "default.raven");
                if (File.Exists(path))
                {
                    Console.WriteLine("Loading data from: {0}", path);
                    Smuggler.Smuggler.ImportData(ravenConfiguration.ServerUrl, path);
                }

                Console.WriteLine("Raven is ready to process requests.");
                Console.WriteLine("Data directory: {0}, Port: {1}", ravenConfiguration.DataDirectory, ravenConfiguration.Port);
                Console.WriteLine("Press the enter key to stop the server or enter 'cls' and then enter to clear the log");
                while (true)
                {
                    var readLine = Console.ReadLine();
                    if (!"CLS".Equals(readLine, StringComparison.InvariantCultureIgnoreCase))
                        break;
                    Console.Clear();
                }
            }
        }
開發者ID:Inferis,項目名稱:ravendb,代碼行數:38,代碼來源:Program.cs

示例8: BootstrapLogger

		static void BootstrapLogger()
		{
            Logger.UseLogger(new Log4NetLogger());

			_appender = new ConsoleAppender();
			_appender.Threshold = Level.Info;
			_appender.Layout = new PatternLayout("%m%n");

			var filter = new LoggerMatchFilter();
			filter.AcceptOnMatch = false;
			filter.LoggerToMatch = "MassTransit";

			_appender.AddFilter(filter);


			BasicConfigurator.Configure(_appender);
		}
開發者ID:cstick,項目名稱:MassTransit,代碼行數:17,代碼來源:Program.cs

示例9: RunInDebugMode

 private static void RunInDebugMode(bool createDefaultDatabase, AnonymousUserAccessMode? anonymousUserAccessMode)
 {
     var consoleAppender = new ConsoleAppender
     {
         Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
     };
     consoleAppender.AddFilter(new LoggerMatchFilter
     {
         AcceptOnMatch = true,
         LoggerToMatch = typeof (HttpServer).FullName
     });
     BasicConfigurator.Configure(consoleAppender);
     var ravenConfiguration = new RavenConfiguration
     {
         ShouldCreateDefaultsWhenBuildingNewDatabaseFromScratch = createDefaultDatabase,
     };
     RavenDbServer.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
     if (anonymousUserAccessMode.HasValue)
         ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
     using (new RavenDbServer(ravenConfiguration))
     {
         Console.WriteLine("Raven is ready to process requests.");
         Console.WriteLine("Press any key to stop the server");
         Console.ReadLine();
     }
 }
開發者ID:torkelo,項目名稱:ravendb,代碼行數:26,代碼來源:Program.cs

示例10: RunInDebugMode

        private static void RunInDebugMode(Raven.Http.AnonymousUserAccessMode? anonymousUserAccessMode, RavenConfiguration ravenConfiguration)
        {
            var consoleAppender = new ConsoleAppender
            {
                Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
            };
            consoleAppender.AddFilter(new LoggerMatchFilter
            {
                AcceptOnMatch = true,
                LoggerToMatch = typeof(HttpServer).FullName
            });
            consoleAppender.AddFilter(new DenyAllFilter());
            BasicConfigurator.Configure(consoleAppender);
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            using (new RavenMqServer(ravenConfiguration))
            {

                Console.WriteLine("RavenMQ is ready to process requests. Build {0}, Version {1}", Queues.BuildVersion, Queues.ProductVersion);
                Console.WriteLine("Data directory: {0}", ravenConfiguration.DataDirectory);
                Console.WriteLine("HostName: {0} Port: {1}, Storage: Munin", ravenConfiguration.HostName ?? "<any>",
                    ravenConfiguration.Port);
                Console.WriteLine("Server Url: {0}", ravenConfiguration.ServerUrl);
                Console.WriteLine("Press <enter> to stop or 'cls' and <enter> to clear the log");
                while (true)
                {
                    var readLine = Console.ReadLine();
                    if (!"CLS".Equals(readLine, StringComparison.InvariantCultureIgnoreCase))
                        break;
                    Console.Clear();
                }
            }
        }
開發者ID:nieve,項目名稱:ravenmq,代碼行數:34,代碼來源:Program.cs


注:本文中的log4net.Appender.ConsoleAppender.AddFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。